home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume90 / comm / dnet / dnet_213 / part02 < prev    next >
Internet Message Format  |  1990-03-27  |  66KB

  1. Path: xanth!cs.odu.edu!Amiga-Request
  2. From: Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator)
  3. Newsgroups: comp.sources.amiga
  4. Subject: v90i119: DNet 2.13 - multiple windows/file transfers over a serial line, Part02/08
  5. Message-ID: <11939@xanth.cs.odu.edu>
  6. Date: 27 Mar 90 01:17:51 GMT
  7. Sender: tadguy@cs.odu.edu
  8. Reply-To: dales%teksce.sce.tek.com@RELAY.CS.NET
  9. Lines: 2868
  10. Approved: tadguy@cs.odu.edu (Tad Guy)
  11. X-Mail-Submissions-To: Amiga@cs.odu.edu
  12. X-Post-Discussions-To: comp.sys.amiga
  13.  
  14. Submitted-by: dales%teksce.sce.tek.com@RELAY.CS.NET
  15. Posting-number: Volume 90, Issue 119
  16. Archive-name: comm/dnet/dnet-2.13/part02
  17.  
  18. #!/bin/sh
  19. # This is a shell archive.  Remove anything before this line, then unpack
  20. # it by saving it into a file and typing "sh file".  To overwrite existing
  21. # files, type "sh file -c".  You can also feed this as standard input via
  22. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  23. # will see the following message at the end:
  24. #        "End of archive 2 (of 8)."
  25. # Contents:  amiga/REQUIREMENTS amiga/dnet/channel.h
  26. #   amiga/dnet/dataconv.c amiga/dnet/globals.c amiga/dnet/time.c
  27. #   amiga/doc/fterm.doc amiga/doc/getfiles.doc amiga/lib/dnetlib.h
  28. #   amiga/lib/dnread.c amiga/lib/dwrite.c amiga/s/dnet.config
  29. #   amiga/server/scli.c amiga/server/snfs.h amiga/server/spasswd.c
  30. #   amiga/server/sprint.c unix/client/draw.c unix/client/dsoc.c
  31. #   unix/dnet/channel.h unix/dnet/dataconv.c unix/dnet/double.c
  32. #   unix/dnet/files.c unix/dnet/net.c unix/server/scopy.c
  33. #   unix/server/sloadav.c unix/server/snfs.h unix/server/sshell.c
  34. # Wrapped by tadguy@xanth on Mon Mar 26 20:14:30 1990
  35. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  36. if test -f 'amiga/REQUIREMENTS' -a "${1}" != "-c" ; then 
  37.   echo shar: Will not clobber existing file \"'amiga/REQUIREMENTS'\"
  38. else
  39. echo shar: Extracting \"'amiga/REQUIREMENTS'\" \(2154 characters\)
  40. sed "s/^X//" >'amiga/REQUIREMENTS' <<'END_OF_FILE'
  41. X
  42. X    DNET (c)Copyright 1987-1989 Matthew Dillon, All Rights Reserved
  43. X
  44. X    Matthew Dillon
  45. X    891 Regal Rd
  46. X    Berkeley, Ca. 94708
  47. X    USA
  48. X
  49. X    ...!ihnp4!ucbvax!dillon     USENET
  50. X    dillon@ucbvax.Berkeley.edu    ARPANET
  51. X    ucbvax.berkeley.edu pub/amiga    ARPANET-FTP
  52. X
  53. X    CHANGES THIS VERSION:
  54. X    7 bit support
  55. X
  56. X    files compile under Lattice C (and don't compile under Aztec C but
  57. X    will eventually compiler under the new Aztec).
  58. X
  59. X
  60. X             REQUIREMENTS TO RUN DNET ON AN AMIGA
  61. X    (This distribution contains the necessary files for running dnet)
  62. X
  63. X    ENV: must exist.  DNet creates and references ENV: variables
  64. X
  65. X    DPIPE:        Required only if you intend to run remote CLIs
  66. X            (SCLI needs it).  A proper Mountlist entry must be
  67. X            added and l:dpipe-handler must be installed.
  68. X
  69. X    DEVS:SERIAL.DEVICE    MUST be the 1.3 serial.device (from your 1.3
  70. X                workbench disk) for reliable operation.
  71. X    S:DNET.SERVERS    must exist and must contain proper paths to
  72. X             the various servers.
  73. X    S:DNET.CONFIG    must exist
  74. X    <dnet binaries>    All the DNet binaries must be in your path
  75. X
  76. X    * read the README file for installation instructions
  77. X
  78. X    * files available via USMail or ARPANet FTP to ucbvax.berkeley.edu,
  79. X        in the pub/amiga directory as dnet.amiga.bin.tar.Z
  80. X
  81. X                FTP/ARPANET ACCESS
  82. X
  83. X    ucbvax.berkeley.edu,    anonymous login, directory pub/amiga
  84. X
  85. X
  86. X           REQUIREMENTS TO COMPILE DNET FOR AN AMIGA
  87. X     (This distribution does not contain all files required for compiling)
  88. X
  89. X           NOTE: SOURCE / MAKEFILES ARE FOR LATTICE C
  90. X           NOTE: the source directory structure must be maintained
  91. X             as is.  You MUST modify the DMakefile's in the
  92. X             source directories to fix the paths to your needs.
  93. X
  94. X    Restore        -My backup/restore program ... only needed if DNet
  95. X             is packaged in a .bak file to unpack it.
  96. X    DMake        -My make program
  97. X    List        -Amiga OS V1.3 C:List (on the 1.3 workbench disk)
  98. X    sup32.lib        -My support library
  99. X    local/*.h        -#include's for my support library
  100. X
  101. X    <dnet-amiga-source> -Source to all the clients, servers, and protocol
  102. X             driver.
  103. X
  104. X    <dnet-amiga-source> is available via USMail or ARPANet FTP.  ARPANET
  105. X
  106. X    FTP: ucbvax.berkeley.edu, anonymous login, pub/amiga directory
  107. X
  108. X
  109. END_OF_FILE
  110. if test 2154 -ne `wc -c <'amiga/REQUIREMENTS'`; then
  111.     echo shar: \"'amiga/REQUIREMENTS'\" unpacked with wrong size!
  112. fi
  113. # end of 'amiga/REQUIREMENTS'
  114. fi
  115. if test -f 'amiga/dnet/channel.h' -a "${1}" != "-c" ; then 
  116.   echo shar: Will not clobber existing file \"'amiga/dnet/channel.h'\"
  117. else
  118. echo shar: Extracting \"'amiga/dnet/channel.h'\" \(1728 characters\)
  119. sed "s/^X//" >'amiga/dnet/channel.h' <<'END_OF_FILE'
  120. X
  121. X/*
  122. X *  CHANNEL.H
  123. X *
  124. X *  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
  125. X *
  126. X *  Channel structures for SCMD_* channel commands.
  127. X */
  128. X
  129. X#ifndef DNET_CHANNEL_H
  130. X#define DNET_CHANNEL_H
  131. X
  132. X#ifndef DNET_H
  133. Xtypedef struct IOStdReq IOSTD;
  134. X#endif
  135. X
  136. X#define CSWITCH struct _CSWITCH
  137. X#define COPEN    struct _COPEN
  138. X#define CCLOSE    struct _CCLOSE
  139. X#define CACKCMD struct _CACKCMD
  140. X#define CEOFCMD struct _CEOFCMD
  141. X#define CIOCTL    struct _CIOCTL
  142. X
  143. XCSWITCH {        /*  SWITCH current data channel */
  144. X    ubyte   chanh;
  145. X    ubyte   chanl;
  146. X};
  147. X
  148. XCOPEN {         /*  OPEN port on channel    */
  149. X    ubyte   chanh;
  150. X    ubyte   chanl;
  151. X    ubyte   porth;
  152. X    ubyte   portl;
  153. X    ubyte   error;    /*  error return 0=ok        */
  154. X    ubyte   pri;
  155. X};
  156. X
  157. XCCLOSE {        /*  CLOSE a channel        */
  158. X    ubyte   chanh;
  159. X    ubyte   chanl;
  160. X};
  161. X
  162. XCACKCMD {        /*  Acknowledge an open/close        */
  163. X    ubyte   chanh;
  164. X    ubyte   chanl;
  165. X    ubyte   error;    /*  ERETRY ENOPORT ECLOSE1 ECLOSE2  */
  166. X    ubyte   filler;
  167. X};
  168. X
  169. XCEOFCMD {        /*  Send [R/W] EOF        */
  170. X    ubyte   chanh;
  171. X    ubyte   chanl;
  172. X    ubyte   flags;
  173. X    ubyte   filler;
  174. X};
  175. X
  176. XCIOCTL {
  177. X    ubyte   chanh;    /* channel            */
  178. X    ubyte   chanl;
  179. X    ubyte   cmd;    /* ioctl command        */
  180. X    ubyte   valh;    /* ioctl value            */
  181. X    ubyte   vall;
  182. X    ubyte   valaux;    /* auxillary field        */
  183. X};
  184. X
  185. X#define CIO_SETROWS    1    /* PTY's only                   */
  186. X#define CIO_SETCOLS    2    /* PTY's only                   */
  187. X#define CIO_STOP    3    /* any channel, flow control    */
  188. X#define CIO_START    4    /* any channel, flow control    */
  189. X#define CIO_FLUSH    5
  190. X#define CIO_MODE    6    /* b0=txlate13->10 b1=localecho b2=LF=CRLF */
  191. X
  192. X#define CHAN    struct _CHAN
  193. X
  194. XCHAN {
  195. X    PORT    *port;
  196. X    IOSTD   *ior;
  197. X    ubyte   state;
  198. X    ubyte   flags;
  199. X    char    pri;    /*  transmit priority    */
  200. X};
  201. X
  202. X#endif
  203. END_OF_FILE
  204. if test 1728 -ne `wc -c <'amiga/dnet/channel.h'`; then
  205.     echo shar: \"'amiga/dnet/channel.h'\" unpacked with wrong size!
  206. fi
  207. # end of 'amiga/dnet/channel.h'
  208. fi
  209. if test -f 'amiga/dnet/dataconv.c' -a "${1}" != "-c" ; then 
  210.   echo shar: Will not clobber existing file \"'amiga/dnet/dataconv.c'\"
  211. else
  212. echo shar: Extracting \"'amiga/dnet/dataconv.c'\" \(2064 characters\)
  213. sed "s/^X//" >'amiga/dnet/dataconv.c' <<'END_OF_FILE'
  214. X
  215. X/*
  216. X *  DATACONV.C
  217. X *
  218. X *  Data Conversion.
  219. X */
  220. X
  221. Xtypedef unsigned char ubyte;
  222. Xtypedef unsigned short uword;
  223. Xtypedef unsigned long ulong;
  224. X
  225. X
  226. Xint
  227. XCompress7(s, db, n)
  228. Xubyte *s;
  229. Xubyte *db;
  230. Xuword n;    /*    actual source bytes */
  231. X{
  232. X    ubyte *d = db;
  233. X
  234. X    while (n) {
  235. X    *d++ = *s++ << 1;
  236. X
  237. X    if (--n == 0)
  238. X        break;
  239. X    d[-1] |= *s >> 6;
  240. X    *d++ = *s++ << 2;
  241. X
  242. X    if (--n == 0)
  243. X        break;
  244. X    d[-1] |= *s >> 5;
  245. X    *d++ = *s++ << 3;
  246. X
  247. X    if (--n == 0)
  248. X        break;
  249. X    d[-1] |= *s >> 4;
  250. X    *d++ = *s++ << 4;
  251. X
  252. X    if (--n == 0)
  253. X        break;
  254. X    d[-1] |= *s >> 3;
  255. X    *d++ = *s++ << 5;
  256. X
  257. X    if (--n == 0)
  258. X        break;
  259. X    d[-1] |= *s >> 2;
  260. X    *d++ = *s++ << 6;
  261. X
  262. X    if (--n == 0)
  263. X        break;
  264. X    d[-1] |= *s >> 1;
  265. X    *d++ = *s++ << 7;
  266. X
  267. X    if (--n == 0)
  268. X        break;
  269. X    d[-1] |= *s++;
  270. X    --n;
  271. X    }
  272. X    return(d - db);
  273. X}
  274. X
  275. Xvoid
  276. XUnCompress7(s, d, n)
  277. Xubyte *s;
  278. Xubyte *d;
  279. Xuword n;    /*    actual destination bytes */
  280. X{
  281. X    while (n) {
  282. X    *d++ = s[0] >> 1;
  283. X
  284. X    if (--n == 0)
  285. X        break;
  286. X    *d++ = ((s[0] << 6) | (s[1] >> 2)) & 0x7F;
  287. X
  288. X    if (--n == 0)
  289. X        break;
  290. X    *d++ = ((s[1] << 5) | (s[2] >> 3)) & 0x7F;
  291. X
  292. X    if (--n == 0)
  293. X        break;
  294. X    *d++ = ((s[2] << 4) | (s[3] >> 4)) & 0x7F;
  295. X
  296. X    if (--n == 0)
  297. X        break;
  298. X    *d++ = ((s[3] << 3) | (s[4] >> 5)) & 0x7F;
  299. X
  300. X    if (--n == 0)
  301. X        break;
  302. X    *d++ = ((s[4] << 2) | (s[5] >> 6)) & 0x7F;
  303. X
  304. X    if (--n == 0)
  305. X        break;
  306. X    *d++ = ((s[5] << 1) | (s[6] >> 7)) & 0x7F;
  307. X
  308. X    if (--n == 0)
  309. X        break;
  310. X    *d++ = s[6] & 0x7F;
  311. X
  312. X    --n;
  313. X    s += 7;
  314. X    }
  315. X}
  316. X
  317. X
  318. Xint
  319. XExpand6(s, db, n)
  320. Xubyte *s;
  321. Xubyte *db;
  322. Xuword n;    /*    actual source bytes */
  323. X{
  324. X    ubyte *d = db;
  325. X
  326. X    while (n) {
  327. X    *d++ = 0x40 | (*s >> 2);
  328. X    *d++ = 0x40 | ((*s++ & 3) << 4);
  329. X    if (--n) {
  330. X        d[-1] |= *s >> 4;
  331. X        *d++ = 0x40 | ((*s++ & 0x0F) << 2);
  332. X        if (--n) {
  333. X        d[-1] |= *s >> 6;
  334. X        *d++ = 0x40 | (*s++ & 0x3F);
  335. X        --n;
  336. X        }
  337. X    }
  338. X    }
  339. X    return(d - db);
  340. X}
  341. X
  342. Xvoid
  343. XUnExpand6(s, d, n)
  344. Xubyte *s;
  345. Xubyte *d;
  346. Xuword n;    /*    actual destination bytes */
  347. X{
  348. X    while (n) {
  349. X    *d++ = (s[0] << 2) | ((s[1] & 0x30) >> 4);
  350. X    if (--n == 0)
  351. X        break;
  352. X    *d++ = (s[1] << 4) | ((s[2] & 0x3C) >> 2);
  353. X    if (--n == 0)
  354. X        break;
  355. X    *d++ = (s[2] << 6) | (s[3] & 0x3F);
  356. X    --n;
  357. X    s += 4;
  358. X    }
  359. X}
  360. X
  361. X
  362. X
  363. END_OF_FILE
  364. if test 2064 -ne `wc -c <'amiga/dnet/dataconv.c'`; then
  365.     echo shar: \"'amiga/dnet/dataconv.c'\" unpacked with wrong size!
  366. fi
  367. # end of 'amiga/dnet/dataconv.c'
  368. fi
  369. if test -f 'amiga/dnet/globals.c' -a "${1}" != "-c" ; then 
  370.   echo shar: Will not clobber existing file \"'amiga/dnet/globals.c'\"
  371. else
  372. echo shar: Extracting \"'amiga/dnet/globals.c'\" \(1871 characters\)
  373. sed "s/^X//" >'amiga/dnet/globals.c' <<'END_OF_FILE'
  374. X
  375. X/*
  376. X *  GLOBALS.C
  377. X *
  378. X *  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
  379. X *
  380. X *    -restart/packet protocol
  381. X *    -dnet->amiga        (DNET.READ)
  382. X *    -amiga->dnet        (DNET.WRITE)
  383. X */
  384. X
  385. X#include "dnet.h"
  386. X
  387. Xint Enable_Abort;
  388. X
  389. XIOT Rto;        /*  Read-Timeout/reset         */
  390. XIOT Wto;        /*  Write-Timeout/retry      */
  391. XIOT Cto;        /*  1 second CD check / idle line*/
  392. XPKT Pkts[9];        /*  data buffers for packets     */
  393. XPKT *RPak[4] = { Pkts+0,Pkts+1,Pkts+2,Pkts+3 };
  394. XPKT *WPak[4] = { Pkts+4,Pkts+5,Pkts+6,Pkts+7 };
  395. XPORT *DNetPort;     /*  Remote Command/Control in        */
  396. XPORT *IOSink;        /*  Return port for ALL IO        */
  397. XPORT *IPCPort;        /*  IPC software control port        */
  398. XCHAN Chan[MAXCHAN];    /*  Channels                */
  399. XLIST TxList;        /*  For pending DNCMD_WRITE reqs.   */
  400. X
  401. Xubyte Rto_act;
  402. Xubyte Wto_act;
  403. Xubyte Cto_act;
  404. Xubyte Cd;        /*  Carrier Detect Status        */
  405. Xubyte Mode7 = 1;
  406. Xuword WChan;        /*  Read and Write channels        */
  407. Xuword RChan;
  408. Xuword RPStart;
  409. Xuword WPStart;
  410. Xuword WPUsed;
  411. Xuword RState;
  412. Xuword Protocol= -1;    /*  0=none 1=xonxoff 2=7wire        */
  413. Xuword Parity = -1;    /*  0=none 1=odd 2=even 3=mark 4=space */
  414. Xshort DDebug;
  415. Xshort PDebug;
  416. Xubyte Restart;        /*  Network restart mode        */
  417. Xubyte OnLine;        /*  Network online            */
  418. Xubyte Quit;        /*  Quit immediately            */
  419. Xshort AutoAnswer = 0;    /*  Security Enable            */
  420. Xshort DialOut = 1;    /*  Security Enable for DialOut     */
  421. Xshort AutoHangup = 0;    /*  On carrier lost (-a opt)            */
  422. Xshort Master8;
  423. Xshort NetworkNum;
  424. Xshort Getty;        /*  begun from a getty            */
  425. Xulong NumCon;        /*  # of connections currently active    */
  426. X            /*     in CHAN_ROPEN/LOPEN/OPEN/CLOSE    */
  427. Xulong WTimeoutVal;
  428. Xulong RTimeoutVal;
  429. Xlong Baud;
  430. Xlong TOBaud;
  431. Xchar *HostName = "";
  432. X
  433. X/*
  434. X *  Status Info
  435. X */
  436. X
  437. Xlong    BytesOut, PacketsOut, PacketsResent;
  438. Xlong    BytesIn , PacketsIn , PacketsNakd;
  439. Xlong    Packets6In, Packets7In, Packets8In;
  440. Xlong    Packets6Out, Packets7Out, Packets8Out;
  441. Xlong    GarbageIn;
  442. X
  443. END_OF_FILE
  444. if test 1871 -ne `wc -c <'amiga/dnet/globals.c'`; then
  445.     echo shar: \"'amiga/dnet/globals.c'\" unpacked with wrong size!
  446. fi
  447. # end of 'amiga/dnet/globals.c'
  448. fi
  449. if test -f 'amiga/dnet/time.c' -a "${1}" != "-c" ; then 
  450.   echo shar: Will not clobber existing file \"'amiga/dnet/time.c'\"
  451. else
  452. echo shar: Extracting \"'amiga/dnet/time.c'\" \(2127 characters\)
  453. sed "s/^X//" >'amiga/dnet/time.c' <<'END_OF_FILE'
  454. X
  455. X/*
  456. X *  TIME.C
  457. X *
  458. X *  Handle IPC alert functions & timekeeping for connect and idle time.
  459. X */
  460. X
  461. X#include "dnet.h"
  462. X#include <stdio.h>
  463. X#include <local/ipc.h>
  464. X
  465. X#define TICKSIZE    10        /*    10 second intervals */
  466. X
  467. Xstatic long TickIdle;
  468. Xstatic long TickConnect;
  469. X
  470. Xstatic long AlertIdle;
  471. Xstatic long AlertConnect;
  472. X
  473. Xstatic char AIWho[64];        /*    app-name to alert   */
  474. Xstatic char ACWho[64];        /*    app-name to alert   */
  475. X
  476. X/*
  477. X *  CTO:    Idle timeout (check carrier)
  478. X *
  479. X */
  480. X
  481. Xvoid
  482. Xdo_cto(ior)
  483. XIOT *ior;
  484. X{
  485. X    if (Cto_act) {
  486. X    AbortIO((IOR *)ior);
  487. X    WaitIO((IOR *)ior);
  488. X    }
  489. X    ior->tr_time.tv_secs = TICKSIZE;
  490. X    ior->tr_time.tv_micro = 0;
  491. X    SendIO((IOR *)ior);
  492. X    Cto_act = 1;
  493. X    if (Cd) {
  494. X    ++TickConnect;
  495. X    ++TickIdle;
  496. X    }
  497. X    if (DDebug)
  498. X    printf("I/C: %ld %ld (%ld %ld)\n", TickIdle, TickConnect, AlertIdle, AlertConnect);
  499. X#ifdef NOTDEF
  500. X    if (AlertConnect && TickConnect > AlertConnect)      /*  alert ipc msg */
  501. X    doipcmsg(ACWho, "\0connalert", 11);
  502. X    if (AlertIdle && TickIdle > AlertIdle)               /*  alert ipc msg */
  503. X    doipcmsg(AIWho, "\0idlealert", 11);
  504. X#endif
  505. X}
  506. X
  507. X/*
  508. X *  Idle/Connect time & alerter vars.  IPC:
  509. X *            resetidle
  510. X *            alertidle <N>    (N in seconds)
  511. X *            alertconn <N>    (N in seconds)
  512. X */
  513. X
  514. Xvoid
  515. XResetIdle()
  516. X{
  517. X    TickIdle = 0;
  518. X}
  519. X
  520. Xvoid
  521. XResetConnect()
  522. X{
  523. X    TickConnect = 0;
  524. X}
  525. X
  526. Xvoid
  527. XLessConnect(n)
  528. X{
  529. X    TickConnect -= n;
  530. X    if (TickConnect < 0)
  531. X    TickConnect = 0;
  532. X}
  533. X
  534. Xvoid
  535. XSetConnectAlert(n, who)
  536. Xchar *who;
  537. X{
  538. X    AlertConnect = (n+(TICKSIZE-1))/TICKSIZE;
  539. X    ACWho[0] = 0;
  540. X    if (who)
  541. X    strcpy(ACWho, who);
  542. X}
  543. X
  544. Xvoid
  545. XSetIdleAlert(n, who)
  546. Xchar *who;
  547. X{
  548. X    AlertIdle = (n+(TICKSIZE-1))/TICKSIZE;
  549. X    AIWho[0] = 0;
  550. X    if (who)
  551. X    strcpy(AIWho, who);
  552. X}
  553. X
  554. XGetIdle()
  555. X{
  556. X    return(TickIdle * TICKSIZE);
  557. X}
  558. X
  559. XGetConnect()
  560. X{
  561. X    return(TickConnect * TICKSIZE);
  562. X}
  563. X
  564. X#ifdef NOTDEF
  565. X
  566. Xdoipcmsg(app, cmd, len)
  567. Xchar *app;
  568. Xchar *cmd;
  569. Xshort len;
  570. X{
  571. X    IPCMSG *msg;
  572. X    long res = 1;
  573. X    IPCMSG *SendIPC();
  574. X
  575. X    if (DDebug)
  576. X    printf("IPC: <%s><%s> = ", app, cmd+1);
  577. X    fflush(stdout);
  578. X    if (msg = SendIPC(app, cmd, len, 0)) {
  579. X    WaitMsg(msg);
  580. X    res = msg->Error;
  581. X    FreeIPC(msg);
  582. X    }
  583. X    if (DDebug)
  584. X    printf("%ld\n", res);
  585. X}
  586. X
  587. X#endif
  588. END_OF_FILE
  589. if test 2127 -ne `wc -c <'amiga/dnet/time.c'`; then
  590.     echo shar: \"'amiga/dnet/time.c'\" unpacked with wrong size!
  591. fi
  592. # end of 'amiga/dnet/time.c'
  593. fi
  594. if test -f 'amiga/doc/fterm.doc' -a "${1}" != "-c" ; then 
  595.   echo shar: Will not clobber existing file \"'amiga/doc/fterm.doc'\"
  596. else
  597. echo shar: Extracting \"'amiga/doc/fterm.doc'\" \(1784 characters\)
  598. sed "s/^X//" >'amiga/doc/fterm.doc' <<'END_OF_FILE'
  599. X
  600. XAMIGA/FTERM
  601. XAMIGA/BBSTERM
  602. X
  603. X    FTERM [-Nnet] [port#] [-c#] [-wcapturefile]
  604. X
  605. X    FTERM opens a standard intuition window and connects to a CSH running on
  606. X    the remote UNIX machine.  If the remote machine is another Amiga, it
  607. X    connects to the terminal-window server (STERM).
  608. X
  609. X    UNIX: The csh runs on a PTY and is NOT named, which means you don't show
  610. X    up in WHO or FINGER, and cannot TALK other people (nor can they talk you).
  611. X    To get a named shell, you must 'rlogin localhost'.  This adds another process
  612. X    to the character-loop.
  613. X
  614. X    The default port# is 8195.    You can also specify another port # to
  615. X    connect to.
  616. X
  617. X    The -N option specifies the network (default = 0).  This is the same
  618. X    network as was specified when you ran DNET (if was not specified, is 0)
  619. X
  620. X    The -c# option (-c7 for example) sets the 'cooked' mode.  Bits are
  621. X    defined as follows:
  622. X
  623. X        bit
  624. X        0   turn keyboard CR's into LFs when sent to remote
  625. X        1   Local Echo (half duplex)
  626. X        2   cause received LFs to generate a CR+LF (i.e. CSI20h)
  627. X
  628. X    -wcapturefile   Specify name of capture file, else "ram:capture".
  629. X
  630. X    Menus:  (partially implemented):  Capture -capture into ram:capture
  631. X
  632. X                      Paste   -pastes from ram:paste
  633. X
  634. X                      Flush   -get rid of buffered data
  635. X                           on remote end (that would
  636. X                           otherwise take a long time
  637. X                           to display)
  638. X
  639. X    BBSTERM is simply FTERM renamed, and uses PORT_BBS (8200) instead of
  640. X    PORT_IALPHATERM (8195).
  641. X
  642. X    RELEASE INFO:
  643. X
  644. X    V1.10   DNET 1.10 release
  645. X
  646. X        -Implements auto window resize and auto-remote-resize
  647. X        -Implements local echo (cooked mode) and buffering
  648. X
  649. X        Remote STERM implements equivalent options and now has the
  650. X        same resize/echo/remote-resize capabilities as FTERM.
  651. X
  652. X    V1.00   Initial Release
  653. X
  654. X
  655. END_OF_FILE
  656. if test 1784 -ne `wc -c <'amiga/doc/fterm.doc'`; then
  657.     echo shar: \"'amiga/doc/fterm.doc'\" unpacked with wrong size!
  658. fi
  659. # end of 'amiga/doc/fterm.doc'
  660. fi
  661. if test -f 'amiga/doc/getfiles.doc' -a "${1}" != "-c" ; then 
  662.   echo shar: Will not clobber existing file \"'amiga/doc/getfiles.doc'\"
  663. else
  664. echo shar: Extracting \"'amiga/doc/getfiles.doc'\" \(1624 characters\)
  665. sed "s/^X//" >'amiga/doc/getfiles.doc' <<'END_OF_FILE'
  666. XUNIX/GETFILES
  667. XAMIGA/GETFILES
  668. X
  669. X    GETFILES [-Nnet#] [-dlocaldir] [-c] file/dir file/dir file/dir ..
  670. X
  671. X    GetFiles file transfer client.    Download the specified files and or
  672. X    dirs from the remote machine into the current directory, or the
  673. X    directory specified if the -d option is used.  Entire directory
  674. X    trees may be downloaded
  675. X
  676. X    The -c "continue" option only downloads files which do not already
  677. X    exist.    For files which do exist, if the local file size is less
  678. X    than the remote file size, the remainder will be downloaded and
  679. X    appended to the local file.
  680. X
  681. X                    SECURITY
  682. X
  683. X    The remote host, if an amiga, will impose security restrictions on
  684. X    those files allowed to be downloaded according to the comment field
  685. X    of said files or any parent directory and the current DNET_READ
  686. X    accesslevel.
  687. X
  688. X    If the remote AMIGA's DNET_READ enviroment variable is set 9 or
  689. X    higher, no access restrictions are imposed.
  690. X
  691. X    If the remote AMIGA's DNET_READ enviroment variable is less than
  692. X    9, the comment field of the requested file or the comment field
  693. X    of any parent directory to that file (checked all the way to the
  694. X    root directory if necessary) must contain a field:
  695. X
  696. X        AC=<n>
  697. X
  698. X    where <n> is a value less than or equal to the security level
  699. X    (DNET_READ enviroment variable).  For example, if the remote user
  700. X    sets the DNET_READ enviroment variable to 5 (normally done by
  701. X    modifying the s:dnet.config file), and then sets the comment field
  702. X    for his GAMES: volume to AC=5, remote users who connect to his
  703. X    amiga will only be allowed to download files from that volume.
  704. X
  705. X    The comment field will be used to house other parameters in the
  706. X    future.
  707. X
  708. END_OF_FILE
  709. if test 1624 -ne `wc -c <'amiga/doc/getfiles.doc'`; then
  710.     echo shar: \"'amiga/doc/getfiles.doc'\" unpacked with wrong size!
  711. fi
  712. # end of 'amiga/doc/getfiles.doc'
  713. fi
  714. if test -f 'amiga/lib/dnetlib.h' -a "${1}" != "-c" ; then 
  715.   echo shar: Will not clobber existing file \"'amiga/lib/dnetlib.h'\"
  716. else
  717. echo shar: Extracting \"'amiga/lib/dnetlib.h'\" \(2125 characters\)
  718. sed "s/^X//" >'amiga/lib/dnetlib.h' <<'END_OF_FILE'
  719. X
  720. X/*
  721. X *  DNETLIB.H
  722. X */
  723. X
  724. X#include "/version.h"
  725. X
  726. X#define CHANN    struct _CHANN
  727. X
  728. X#define NAMELEN sizeof("DNET.PORT.XXXXX")
  729. X#define NAMEPAT "DNET.PORT.%ld"
  730. X
  731. XCHANN {
  732. X    PORT    port;        /*    receive data, replies        */
  733. X    PORT    *dnetport;        /*    dnet's master port          */
  734. X    LIST    rdylist;        /*    ready to be read        */
  735. X    uword   chan;        /*    channel # for open channels */
  736. X    ubyte   eof;        /*    channel remotely closed/eof */
  737. X    ubyte   filler;
  738. X    int     qlen;        /*    allowed write queue size    */
  739. X    int     queued;        /*    current # packets queued    */
  740. X};
  741. X
  742. X#define EFATAL    0
  743. X#define EWARN    1
  744. X#define EDEBUG    2
  745. X
  746. X#define NT_REQUEUE  0x40
  747. X
  748. X#define elog(how, ctl, data)    _elog(__LINE__,__FILE__,how,ctl,data)
  749. X
  750. Xextern char *Program;
  751. X
  752. X/*
  753. X *  Routines
  754. X */
  755. X
  756. Xextern void Version    ARGS((char *, char *, char *));
  757. Xextern PORT *DListen    ARGS((uword));
  758. Xextern void DUnListen    ARGS((PORT *));
  759. Xextern PORT *DAccept    ARGS((PORT *));
  760. Xextern int  DNAAccept    ARGS((PORT *));
  761. Xextern void DPri    ARGS((void *, int));
  762. Xextern PORT *DOpen    ARGS((char *, uword, int, int));
  763. Xextern int  DCheckEof    ARGS((void *));
  764. Xextern short DGetIoctl    ARGS((void *, short *, char *));
  765. Xextern long DNRead  ARGS((void *, void *, long));
  766. Xextern long DRead   ARGS((void *, void *, long));
  767. Xextern void DQueue  ARGS((void *, long));
  768. Xextern long DWrite  ARGS((void *, void *, long));
  769. Xextern void DEof    ARGS((void *));
  770. Xextern void DIoctl  ARGS((void *, ubyte, uword, ubyte));
  771. Xextern int  DStat   ARGS((char *, APTR, long));
  772. Xextern int  DQuit   ARGS((char *));
  773. Xextern void DClose  ARGS((void *));
  774. Xextern int  DExec   ARGS((void *, char *));
  775. Xextern short WaitQueue    ARGS((void *, IOSTD *));
  776. X
  777. Xextern void *MakeChannel    ARGS((IOSTD *, char *));
  778. Xextern void DeleteChannel   ARGS((void *));
  779. Xextern void FixSignal        ARGS((void *));
  780. Xextern int  GetEnvVal        ARGS((char *));
  781. Xextern int  OpenCfgFile     ARGS((void));
  782. Xextern char *GetCfgLine     ARGS((char *));
  783. Xextern void CloseCfgFile    ARGS((void));
  784. Xextern void GetOneCfg        ARGS((char *));
  785. Xextern int  ExtractFieldVal ARGS((char *, char *, short *));
  786. X
  787. Xextern void _elog   ARGS((int, char *, int, char *, void *));
  788. X
  789. END_OF_FILE
  790. if test 2125 -ne `wc -c <'amiga/lib/dnetlib.h'`; then
  791.     echo shar: \"'amiga/lib/dnetlib.h'\" unpacked with wrong size!
  792. fi
  793. # end of 'amiga/lib/dnetlib.h'
  794. fi
  795. if test -f 'amiga/lib/dnread.c' -a "${1}" != "-c" ; then 
  796.   echo shar: Will not clobber existing file \"'amiga/lib/dnread.c'\"
  797. else
  798. echo shar: Extracting \"'amiga/lib/dnread.c'\" \(2137 characters\)
  799. sed "s/^X//" >'amiga/lib/dnread.c' <<'END_OF_FILE'
  800. X
  801. X/*
  802. X *  DNRead.C
  803. X */
  804. X
  805. X#include "lib.h"
  806. X
  807. Xlong
  808. XDNRead(_chan, _buf, bytes)
  809. Xvoid *_chan;
  810. Xvoid *_buf;
  811. Xlong bytes;
  812. X{
  813. X    CHANN *chan = (CHANN *)_chan;
  814. X    char *buf = (char *)_buf;
  815. X    IOSTD *ior;
  816. X    int len = 0;
  817. X    long n;
  818. X
  819. X    if (chan->eof)
  820. X    return(-1);
  821. X    while (bytes && ((ior = (IOSTD *)RemHead(&chan->rdylist)) || (ior = (IOSTD *)GetMsg(&chan->port)))) {
  822. X#ifdef DEBUG
  823. X    printf("IOR %08lx cmd %d len %d act %d\n", ior, ior->io_Command, ior->io_Length, ior->io_Actual);
  824. X#endif
  825. X    if (ior->io_Message.mn_Node.ln_Type == NT_REPLYMSG) {
  826. X        if (!chan->queued)
  827. X#ifdef DEBUG
  828. X        puts("DNRead: Software Error");
  829. X#else
  830. X        ;
  831. X#endif
  832. X        else
  833. X        --chan->queued;
  834. X        if (ior->io_Length)
  835. X        FreeMem(ior->io_Data, ior->io_Length);
  836. X        FreeMem(ior, sizeof(IOSTD));
  837. X        continue;
  838. X    }
  839. X    switch(ior->io_Command) {
  840. X    case DNCMD_CLOSE:
  841. X    case DNCMD_EOF:
  842. X        chan->eof = 1;
  843. X        ReplyMsg((MSG *)ior);
  844. X        break;
  845. X    case DNCMD_IOCTL:
  846. X        if (ior->io_Message.mn_Node.ln_Type == NT_REQUEUE)
  847. X        AddHead(&chan->rdylist, (NODE *)ior);
  848. X        else
  849. X        AddTail(&chan->rdylist, (NODE *)ior);
  850. X        ior->io_Message.mn_Node.ln_Type = NT_REQUEUE;
  851. X        if (len == 0)
  852. X        len = -2;
  853. X        goto done;
  854. X    case DNCMD_WRITE:
  855. X#ifdef DEBUG
  856. X        printf("IOR LEN/ACT %ld/%ld\n", ior->io_Length, ior->io_Actual);
  857. X#endif
  858. X        n = ior->io_Length - ior->io_Actual;
  859. X#ifdef DEBUG
  860. X        if (n < 0)
  861. X        puts("len fail");
  862. X#endif
  863. X        if (n <= bytes) {
  864. X        BMov((char *)ior->io_Data + ior->io_Actual, buf, n);
  865. X        bytes -= n;
  866. X        len += n;
  867. X        buf += n;
  868. X        ReplyMsg((MSG *)ior);
  869. X        } else {
  870. X        BMov((char *)ior->io_Data + ior->io_Actual, buf, bytes);
  871. X        len += bytes;
  872. X        ior->io_Actual += bytes;
  873. X        bytes = 0;
  874. X        if (ior->io_Message.mn_Node.ln_Type == NT_REQUEUE)
  875. X            AddHead(&chan->rdylist, (NODE *)ior);
  876. X        else
  877. X            AddTail(&chan->rdylist, (NODE *)ior);
  878. X        ior->io_Message.mn_Node.ln_Type = NT_REQUEUE;
  879. X        }
  880. X        break;
  881. X    default:
  882. X        ior->io_Error = 1;
  883. X        ReplyMsg((MSG *)ior);
  884. X    }
  885. X    }
  886. X#ifdef DEBUG
  887. X    puts("DONE1");
  888. X#endif
  889. Xdone:
  890. X    FixSignal(chan);
  891. X    if (chan->eof)
  892. X    SetSignal(1 << chan->port.mp_SigBit, 1 << chan->port.mp_SigBit);
  893. X#ifdef DEBUG
  894. X    printf("RETURN %ld\n", len);
  895. X#endif
  896. X    return(len);
  897. X}
  898. X
  899. END_OF_FILE
  900. if test 2137 -ne `wc -c <'amiga/lib/dnread.c'`; then
  901.     echo shar: \"'amiga/lib/dnread.c'\" unpacked with wrong size!
  902. fi
  903. # end of 'amiga/lib/dnread.c'
  904. fi
  905. if test -f 'amiga/lib/dwrite.c' -a "${1}" != "-c" ; then 
  906.   echo shar: Will not clobber existing file \"'amiga/lib/dwrite.c'\"
  907. else
  908. echo shar: Extracting \"'amiga/lib/dwrite.c'\" \(1177 characters\)
  909. sed "s/^X//" >'amiga/lib/dwrite.c' <<'END_OF_FILE'
  910. X
  911. X/*
  912. X *  DWrite.c
  913. X */
  914. X
  915. X#include "lib.h"
  916. X
  917. Xlong
  918. XDQueueFull(_chan)
  919. Xvoid *_chan;
  920. X{
  921. X    CHANN *chan = (CHANN *)_chan;
  922. X
  923. X    return (chan->qlen && (chan->queued > chan->qlen));
  924. X}
  925. X
  926. Xlong
  927. XDWrite(_chan, _buf, bytes)
  928. Xvoid *_chan;
  929. Xvoid *_buf;
  930. Xlong bytes;
  931. X{
  932. X    int error = bytes;
  933. X    CHANN *chan = (CHANN *)_chan;
  934. X    char *buf = (char *)_buf;
  935. X
  936. X    if (chan->qlen) {
  937. X    if (WaitQueue(chan, NULL) >= 0) {
  938. X        IOSTD *ior = AllocMem(sizeof(IOSTD), MEMF_CLEAR|MEMF_PUBLIC);
  939. X        ior->io_Command = DNCMD_WRITE;
  940. X        ior->io_Unit = (void *)chan->chan;
  941. X        ior->io_Offset = (long)chan;
  942. X        ior->io_Message.mn_ReplyPort = (PORT *)chan;
  943. X        ior->io_Data = AllocMem(bytes, MEMF_PUBLIC);
  944. X        ior->io_Length = bytes;
  945. X        BMov(buf, ior->io_Data, bytes);
  946. X        PutMsg(chan->dnetport, (MSG *)ior);
  947. X        ++chan->queued;
  948. X    } else {
  949. X        error = -1;
  950. X    }
  951. X    } else {
  952. X    IOSTD ior;
  953. X    ior.io_Command = DNCMD_WRITE;
  954. X    ior.io_Unit = (void *)chan->chan;
  955. X    ior.io_Offset = (long)chan;
  956. X    ior.io_Message.mn_ReplyPort = (PORT *)chan;
  957. X    ior.io_Data = (APTR)buf;
  958. X    ior.io_Length = bytes;
  959. X    PutMsg(chan->dnetport, (MSG *)&ior);
  960. X    WaitMsg(&ior);
  961. X    if (ior.io_Error)
  962. X        error = -1;
  963. X    }
  964. X    FixSignal(chan);
  965. X    return(error);
  966. X}
  967. X
  968. END_OF_FILE
  969. if test 1177 -ne `wc -c <'amiga/lib/dwrite.c'`; then
  970.     echo shar: \"'amiga/lib/dwrite.c'\" unpacked with wrong size!
  971. fi
  972. # end of 'amiga/lib/dwrite.c'
  973. fi
  974. if test -f 'amiga/s/dnet.config' -a "${1}" != "-c" ; then 
  975.   echo shar: Will not clobber existing file \"'amiga/s/dnet.config'\"
  976. else
  977. echo shar: Extracting \"'amiga/s/dnet.config'\" \(1138 characters\)
  978. sed "s/^X//" >'amiga/s/dnet.config' <<'END_OF_FILE'
  979. X
  980. XLOGF ram:dnet.log
  981. X
  982. X# Commands to set the baud rate, determined by messages that occur
  983. X# before carrier detect.  Only scanned if -a option used
  984. X
  985. XAUTA 19200  "CONNECT"
  986. XAUTA 19200  "CONNECT 300"
  987. XAUTA 19200  "CONNECT 1200"
  988. XAUTA 19200  "CONNECT 2400"
  989. XAUTA 19200  "CONNECT 9600"
  990. XAUTA 19200  "CONNECT 19200"
  991. X
  992. X# Commands to Reset the Modem.    Only scanned if -a option used
  993. X
  994. XRESM AT
  995. XRESM AT
  996. XRESM ATS0=2
  997. XDISM +++
  998. X
  999. X# Auto-Reset enviroment variable security level to this (DNET_LEVEL)
  1000. X#
  1001. X#   The default is ENVO.  The -a option for DNET selects ENVA, -X selects
  1002. X#   ENVM.  Note that the default assumes a hostile enviroment.
  1003. X#
  1004. X# ENVA    -auto answer (-a) option enviroment
  1005. X# ENVO    -originate (you are dialing up somebody else) option enviroment
  1006. X# ENVM    -manual (no -a) option enviroment
  1007. X#
  1008. X#   LEVEL   overall access rights
  1009. X#   READ    basic access rights for reading files from this machine
  1010. X#   WRITE   basic access rights for writing files to this machine
  1011. X
  1012. XENVA DNET_LEVEL     0
  1013. XENVA DNET_READ        0
  1014. XENVA DNET_WRITE     0
  1015. X
  1016. XENVO DNET_LEVEL     1
  1017. XENVO DNET_READ        1
  1018. XENVO DNET_WRITE     1
  1019. X
  1020. XENVM DNET_LEVEL     9
  1021. XENVM DNET_READ        9
  1022. XENVM DNET_WRITE     9
  1023. X
  1024. END_OF_FILE
  1025. if test 1138 -ne `wc -c <'amiga/s/dnet.config'`; then
  1026.     echo shar: \"'amiga/s/dnet.config'\" unpacked with wrong size!
  1027. fi
  1028. # end of 'amiga/s/dnet.config'
  1029. fi
  1030. if test -f 'amiga/server/scli.c' -a "${1}" != "-c" ; then 
  1031.   echo shar: Will not clobber existing file \"'amiga/server/scli.c'\"
  1032. else
  1033. echo shar: Extracting \"'amiga/server/scli.c'\" \(2834 characters\)
  1034. sed "s/^X//" >'amiga/server/scli.c' <<'END_OF_FILE'
  1035. X
  1036. X/*
  1037. X *  SCLI.C
  1038. X *
  1039. X *  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
  1040. X *
  1041. X *  SHELL SERVER.   THIS REQUIRES MY PIPE DEVICE TO WORK!!!!!!!!!!
  1042. X *
  1043. X *  Port #8196
  1044. X *
  1045. X *  Only one connection accepted at a time in this baby.
  1046. X *  HUGE CLUDGE!!!
  1047. X *
  1048. X *  DNET_LEVEL must be 9 or higher.
  1049. X */
  1050. X
  1051. X#include "defs.h"
  1052. X
  1053. Xchar Buf[4096];
  1054. X
  1055. Xint
  1056. Xbrk()
  1057. X{
  1058. X    return(0);
  1059. X}
  1060. X
  1061. Xvoid
  1062. X#ifdef LATTICE
  1063. X_main(str)
  1064. X#else
  1065. X_main(len,str)
  1066. X#endif
  1067. Xchar *str;
  1068. X{
  1069. X    struct MsgPort *port;
  1070. X    PROC    *proc = (PROC *)FindTask(NULL);
  1071. X    void    *chan;
  1072. X    long    mask, rmask;
  1073. X    long    namei = (long)proc;
  1074. X    APTR    oldwptr;
  1075. X    /*short   mycis = 0, mycos = 0;*/
  1076. X
  1077. X    onbreak(brk);
  1078. X
  1079. X    if (strncmp(str, "__dnet", 6) != 0) {
  1080. X    Version("SCli", VERSION, SCLI_VERSION);
  1081. X    _exit(0);
  1082. X    }
  1083. X
  1084. X    port = DListen(PORT_AMIGASHELL);
  1085. X    WaitPort(&proc->pr_MsgPort);
  1086. X    ReplyMsg(GetMsg(&proc->pr_MsgPort));
  1087. X    if (!port)
  1088. X    _exit(1);
  1089. X    mask = SIGBREAKF_CTRL_C|(1 << port->mp_SigBit);
  1090. X    oldwptr = proc->pr_WindowPtr;
  1091. X    proc->pr_WindowPtr = (APTR)-1;
  1092. X
  1093. X    /* REMOVED
  1094. X    proc->pr_ConsoleTask = DeviceProc("dpipe:");
  1095. X    if (!proc->pr_CIS) {
  1096. X    mycis = 1;
  1097. X    proc->pr_CIS = Open("nil:", 1006);
  1098. X    }
  1099. X    if (!proc->pr_COS) {
  1100. X    mycos = 1;
  1101. X    proc->pr_COS = Open("nil:", 1006);
  1102. X    }
  1103. X    */
  1104. X    for (;;) {
  1105. X    rmask = Wait(mask);
  1106. X    if (rmask & SIGBREAKF_CTRL_C)
  1107. X        break;
  1108. X    if (chan = DAccept(port)) {
  1109. X        long fh;
  1110. X        long mask;
  1111. X        long fhmask, smask;
  1112. X        short sig;
  1113. X        char pname[16];
  1114. X        char buf[64];
  1115. X
  1116. X        if (GetEnvVal(DNET_LEVEL) < 9) {
  1117. X        DWrite(chan, "env:DNET_LEVEL must be >= 9\n", 18);
  1118. X        DClose(chan);
  1119. X        continue;
  1120. X        }
  1121. X
  1122. X        sprintf(pname, "%08lx", namei++);
  1123. X        sprintf(buf, "newshell <nil: >nil: dpipe:%s/St FROM s:remote-startup", pname);
  1124. X        DExec(chan, buf);
  1125. X        sig = AllocSignal(-1);
  1126. X        fhmask = 1 << sig;
  1127. X        smask = 1 << ((struct MsgPort *)chan)->mp_SigBit;
  1128. X        sprintf(buf, "dpipe:%s/Mctns%ld", pname, sig);
  1129. X        fh = (long)Open(buf, 1006);
  1130. X        if (fh) {
  1131. X        char notdone = 1;
  1132. X        DWrite(chan, "Amiga CLI running\n", 20);
  1133. X        while (notdone) {
  1134. X            char buf[256];
  1135. X            int n;
  1136. X            mask = Wait(fhmask | smask | SIGBREAKF_CTRL_C);
  1137. X            while ((n = Read(fh, buf, 256)) > 0) {
  1138. X            DWrite(chan, buf, n);
  1139. X            }
  1140. X            if (n < 0)
  1141. X            notdone = 0;
  1142. X            while ((n = DNRead(chan, buf, 256)) > 0) {
  1143. X            /* REMOVED
  1144. X            DWrite(chan, buf, n);
  1145. X            */
  1146. X            Write(fh, buf, n);
  1147. X            }
  1148. X            if (n == -2) {
  1149. X            short pv;
  1150. X            char pa;
  1151. X            DGetIoctl(chan, &pv, &pa);
  1152. X            } else if (n < 0)
  1153. X            notdone = 0;
  1154. X        }
  1155. X        Write(fh, "ENDCLI\n", 7);
  1156. X        Write(fh, "ENDCLI\n", 7);
  1157. X        Close(fh);
  1158. X        }
  1159. X        DClose(chan);
  1160. X        FreeSignal(sig);
  1161. X        puts("DONE");
  1162. X    }
  1163. X    }
  1164. X    proc->pr_WindowPtr = oldwptr;
  1165. X
  1166. X    /* REMOVED
  1167. X    if (mycos) {
  1168. X    Close(proc->pr_COS);
  1169. X    proc->pr_COS = NULL;
  1170. X    }
  1171. X    if (mycis) {
  1172. X    Close(proc->pr_CIS);
  1173. X    proc->pr_CIS = NULL;
  1174. X    }
  1175. X    */
  1176. X    DUnListen(port);
  1177. X}
  1178. X
  1179. X
  1180. X
  1181. END_OF_FILE
  1182. if test 2834 -ne `wc -c <'amiga/server/scli.c'`; then
  1183.     echo shar: \"'amiga/server/scli.c'\" unpacked with wrong size!
  1184. fi
  1185. # end of 'amiga/server/scli.c'
  1186. fi
  1187. if test -f 'amiga/server/snfs.h' -a "${1}" != "-c" ; then 
  1188.   echo shar: Will not clobber existing file \"'amiga/server/snfs.h'\"
  1189. else
  1190. echo shar: Extracting \"'amiga/server/snfs.h'\" \(1617 characters\)
  1191. sed "s/^X//" >'amiga/server/snfs.h' <<'END_OF_FILE'
  1192. X
  1193. X#define ulong unsigned long
  1194. X#define ubyte unsigned char
  1195. X#define uword unsigned short
  1196. X
  1197. Xtypedef struct {
  1198. X    long    ds_Days;
  1199. X    long    ds_Minute;
  1200. X    long    ds_Tick;
  1201. X} STAMP;
  1202. X
  1203. Xtypedef struct {
  1204. X    long    DirHandle;        /*  relative to directory (0=root)  */
  1205. X    uword   Modes;        /*  open modes                */
  1206. X} OpOpen;
  1207. X
  1208. Xtypedef struct {
  1209. X    long    Handle;
  1210. X    ulong   Prot;
  1211. X    long    Type;
  1212. X    long    Size;
  1213. X    STAMP   Date;
  1214. X} RtOpen;
  1215. X
  1216. X
  1217. Xtypedef struct {
  1218. X    long    Handle;     /*  file handle to read from        */
  1219. X    long    Bytes;        /*  # of bytes to read            */
  1220. X} OpRead;
  1221. X
  1222. Xtypedef struct {
  1223. X    long    Bytes;        /*  < 0 == error            */
  1224. X} RtRead;
  1225. X
  1226. Xtypedef struct {
  1227. X    long   Handle;     /*  file handle to read from        */
  1228. X    long    Bytes;        /*  # of bytes to read            */
  1229. X} OpWrite;
  1230. X
  1231. Xtypedef struct {
  1232. X    long    Bytes;        /*  < 0 == error            */
  1233. X} RtWrite;
  1234. X
  1235. Xtypedef struct {
  1236. X    long    Handle;
  1237. X} OpClose;
  1238. X
  1239. Xtypedef struct {
  1240. X    long    Handle;
  1241. X    long    Offset;
  1242. X    long    How;
  1243. X} OpSeek;
  1244. X
  1245. Xtypedef struct {
  1246. X    long    OldOffset;
  1247. X    long    NewOffset;        /*    -1 = error  */
  1248. X} RtSeek;
  1249. X
  1250. Xtypedef struct {
  1251. X    long    Handle;
  1252. X} OpParent;
  1253. X
  1254. Xtypedef RtOpen RtParent;
  1255. X
  1256. Xtypedef struct {
  1257. X    long    DirHandle;
  1258. X} OpDelete;
  1259. X
  1260. Xtypedef struct {
  1261. X    long    Error;
  1262. X} RtDelete;
  1263. X
  1264. Xtypedef OpDelete OpCreateDir;
  1265. Xtypedef RtParent RtCreateDir;
  1266. X
  1267. Xtypedef struct {
  1268. X    long    Handle;
  1269. X    long    Index;
  1270. X} OpNextDir;
  1271. X
  1272. Xtypedef RtOpen RtNextDir;
  1273. X
  1274. Xtypedef struct {
  1275. X    long    Handle;
  1276. X} OpDup;
  1277. X
  1278. Xtypedef RtOpen    RtDup;
  1279. X
  1280. Xtypedef struct {
  1281. X    long    DirHandle1;
  1282. X    long    DirHandle2;
  1283. X} OpRename;
  1284. X
  1285. Xtypedef struct {
  1286. X    long    Error;
  1287. X} RtRename;
  1288. X
  1289. END_OF_FILE
  1290. if test 1617 -ne `wc -c <'amiga/server/snfs.h'`; then
  1291.     echo shar: \"'amiga/server/snfs.h'\" unpacked with wrong size!
  1292. fi
  1293. # end of 'amiga/server/snfs.h'
  1294. fi
  1295. if test -f 'amiga/server/spasswd.c' -a "${1}" != "-c" ; then 
  1296.   echo shar: Will not clobber existing file \"'amiga/server/spasswd.c'\"
  1297. else
  1298. echo shar: Extracting \"'amiga/server/spasswd.c'\" \(3336 characters\)
  1299. sed "s/^X//" >'amiga/server/spasswd.c' <<'END_OF_FILE'
  1300. X
  1301. X/*
  1302. X *  SPASSWD.C
  1303. X *
  1304. X *  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
  1305. X *
  1306. X *  PASSWORD SERVER
  1307. X *
  1308. X *  user-password entry.  USER entries in s:dnet.config are scanned for
  1309. X *  a match and the various dnet enviroment variables are set accordingly.
  1310. X */
  1311. X
  1312. X#include "defs.h"
  1313. X
  1314. Xint do_password ARGS((void *));
  1315. Xvoid DPuts ARGS((void *, char *));
  1316. Xint DGetLine ARGS((void *, char *, short));
  1317. X
  1318. Xint
  1319. Xbrk()
  1320. X{
  1321. X    return(0);
  1322. X}
  1323. X
  1324. Xvoid
  1325. X#ifdef LATTICE
  1326. X_main(str)
  1327. X#else
  1328. X_main(len,str)
  1329. X#endif
  1330. Xchar *str;
  1331. X{
  1332. X    struct MsgPort *port;
  1333. X    PROC    *myproc = (PROC *)FindTask(NULL);
  1334. X    void    *chan;
  1335. X    long    mask, rmask;
  1336. X    short   res;
  1337. X
  1338. X    onbreak(brk);
  1339. X
  1340. X    if (strncmp(str, "__dnet", 6) != 0) {
  1341. X    Version("SPasswd", VERSION, SPASSWD_VERSION);
  1342. X    _exit(0);
  1343. X    }
  1344. X
  1345. X    port = DListen(PORT_PASSWD);
  1346. X    WaitPort(&myproc->pr_MsgPort);
  1347. X    ReplyMsg(GetMsg(&myproc->pr_MsgPort));
  1348. X
  1349. X    mask = SIGBREAKF_CTRL_C|(1 << port->mp_SigBit);
  1350. X    for (;;) {
  1351. X    rmask = Wait(mask);
  1352. X    if (rmask & SIGBREAKF_CTRL_C)
  1353. X        break;
  1354. X    while (chan = DAccept(port)) {
  1355. X        res = do_password(chan);
  1356. X        Delay(10L);     /*  prevent name scan   */
  1357. X        if (res)
  1358. X        DPuts(chan, "user-password accepted\n");
  1359. X        else
  1360. X        DPuts(chan, "user-password failed\n");
  1361. X        Delay(50L);     /*  prevent name scan   */
  1362. X        DClose(chan);
  1363. X    }
  1364. X    }
  1365. X    DUnListen(port);
  1366. X}
  1367. X
  1368. Xint
  1369. Xdo_password(chan)
  1370. Xvoid *chan;
  1371. X{
  1372. X    static char user[64];
  1373. X    static char pass[64];
  1374. X    static char buf[128];
  1375. X    static char suser[64];
  1376. X    static char spass[64];
  1377. X    short res;
  1378. X    long fh;
  1379. X    short i, n;
  1380. X    int s_level, s_read, s_write;
  1381. X
  1382. X    DPuts(chan, "User Name: ");
  1383. X    res = DGetLine(chan, user, 64);
  1384. X    if (res < 0)
  1385. X    return(0);
  1386. X    DIoctl(chan, CIO_MODE, 0, 0);
  1387. X    DPuts(chan, "Password : ");
  1388. X    res = DGetLine(chan, pass, 64);
  1389. X    DIoctl(chan, CIO_MODE, 7, 0);
  1390. X    if (res < 0)
  1391. X    return(0);
  1392. X
  1393. X    /*
  1394. X     *    search for USER entry in s:dnet.config
  1395. X     */
  1396. X
  1397. X    fh = Open("s:dnet.config", 1005);
  1398. X    if (fh == NULL) {
  1399. X    DPuts(chan, "s:dnet.config does not exist\n");
  1400. X    return(0);
  1401. X    }
  1402. X    while ((n = Read(fh, buf, 256)) > 0) {
  1403. X    for (i = 0; i < n - 1; ++i) {
  1404. X        if (buf[i] == '\n')
  1405. X        break;
  1406. X    }
  1407. X    buf[i] = 0;
  1408. X    Seek(fh, (i + 1) - n, 0);
  1409. X    if (strncmp(buf, "USER", 4) == 0) {
  1410. X        suser[0] = spass[0] = 0;
  1411. X        s_level = s_read = s_write = 0;
  1412. X        sscanf(buf + 4, "%s %s %d %d %d", suser, spass, &s_level, &s_read, &s_write);
  1413. X        if (strcmp(user, suser) == 0 && strcmp(pass, spass) == 0) {
  1414. X        Close(fh);
  1415. X        sprintf(buf, "%d", s_level);
  1416. X        SetDEnv(DNET_LEVEL, buf);
  1417. X        sprintf(buf, "%d", s_read);
  1418. X        SetDEnv(DNET_READ, buf);
  1419. X        sprintf(buf, "%d", s_write);
  1420. X        SetDEnv(DNET_WRITE, buf);
  1421. X        return(1);
  1422. X        }
  1423. X    }
  1424. X    }
  1425. X    Close(fh);
  1426. X    return(0);
  1427. X}
  1428. X
  1429. Xvoid
  1430. XDPuts(chan, str)
  1431. Xvoid *chan;
  1432. Xchar *str;
  1433. X{
  1434. X    DWrite(chan, str, strlen(str));
  1435. X}
  1436. X
  1437. Xint
  1438. XDGetLine(chan, buf, max)
  1439. Xvoid *chan;
  1440. Xchar *buf;
  1441. Xshort max;
  1442. X{
  1443. X    short i = 0;
  1444. X    short n;
  1445. X    short notdone = 1;
  1446. X    char c;
  1447. X
  1448. X    while (notdone) {
  1449. X    n = DRead(chan, &c, 1);
  1450. X    if (n == 0) {   /*  ioctl, ignore   */
  1451. X        short pv;
  1452. X        char pa;
  1453. X        DGetIoctl(chan, &pv, &pa);
  1454. X        continue;
  1455. X    }
  1456. X    if (n < 0) {
  1457. X        buf[i] = 0;
  1458. X        return(-1);
  1459. X    }
  1460. X    switch(c) {
  1461. X    case 8:     /*    BS  */
  1462. X        if (i)
  1463. X        --i;
  1464. X        break;
  1465. X    case 10:    /*    eol */
  1466. X    case 13:
  1467. X        notdone = 0;
  1468. X        break;
  1469. X    default:
  1470. X        if (i < max - 1)
  1471. X        buf[i++] = c;
  1472. X        break;
  1473. X    }
  1474. X    }
  1475. X    buf[i] = 0;
  1476. X    return(1);
  1477. X}
  1478. X
  1479. END_OF_FILE
  1480. if test 3336 -ne `wc -c <'amiga/server/spasswd.c'`; then
  1481.     echo shar: \"'amiga/server/spasswd.c'\" unpacked with wrong size!
  1482. fi
  1483. # end of 'amiga/server/spasswd.c'
  1484. fi
  1485. if test -f 'amiga/server/sprint.c' -a "${1}" != "-c" ; then 
  1486.   echo shar: Will not clobber existing file \"'amiga/server/sprint.c'\"
  1487. else
  1488. echo shar: Extracting \"'amiga/server/sprint.c'\" \(1398 characters\)
  1489. sed "s/^X//" >'amiga/server/sprint.c' <<'END_OF_FILE'
  1490. X
  1491. X/*
  1492. X *  SPRINT.C
  1493. X *
  1494. X *  DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
  1495. X *
  1496. X *  PRINTER SERVER
  1497. X *
  1498. X *  Accepting one connection at a time, dump the file to PRT:
  1499. X *
  1500. X *  DNET_WRITE    must be 6 or higher for this function to work.
  1501. X */
  1502. X
  1503. X#include "defs.h"
  1504. X
  1505. Xvoid printfile ARGS((void *));
  1506. X
  1507. Xint
  1508. Xbrk()
  1509. X{
  1510. X    return(0);
  1511. X}
  1512. X
  1513. Xvoid
  1514. X#ifdef LATTICE
  1515. X_main(str)
  1516. X#else
  1517. X_main(len,str)
  1518. X#endif
  1519. Xchar *str;
  1520. X{
  1521. X    PORT    *port;
  1522. X    PROC    *myproc = (PROC *)FindTask(NULL);
  1523. X    void    *chan;
  1524. X    long    mask, rmask;
  1525. X
  1526. X    onbreak(brk);
  1527. X
  1528. X    if (strncmp(str, "__dnet", 6) != 0) {
  1529. X    Version("SPrint", VERSION, SPRINT_VERSION);
  1530. X    _exit(0);
  1531. X    }
  1532. X
  1533. X    port = DListen(PORT_PRINTER);
  1534. X    WaitPort(&myproc->pr_MsgPort);
  1535. X    ReplyMsg(GetMsg(&myproc->pr_MsgPort));
  1536. X
  1537. X    mask = SIGBREAKF_CTRL_C|(1 << port->mp_SigBit);
  1538. X    for (;;) {
  1539. X    rmask = Wait(mask);
  1540. X    if (rmask & SIGBREAKF_CTRL_C)
  1541. X        break;
  1542. X    while (chan = DAccept(port)) {
  1543. X        if (GetEnvVal(DNET_WRITE) >= 6) {
  1544. X        DWrite(chan, "Accepted\n", 9);
  1545. X        printfile(chan);
  1546. X        } else {
  1547. X        DWrite(chan, "Permission Denied\n", 18);
  1548. X        }
  1549. X        DClose(chan);
  1550. X    }
  1551. X    }
  1552. X    DUnListen(port);
  1553. X}
  1554. X
  1555. Xvoid
  1556. Xprintfile(chan)
  1557. Xvoid *chan;
  1558. X{
  1559. X    long n, fh;
  1560. X    char rc = 0;
  1561. X    char buf[256];
  1562. X
  1563. X    if (fh = Open("PRT:", 1006)) {
  1564. X    rc = 1;
  1565. X    while ((n = DRead(chan, buf, 256)) > 0) {
  1566. X        if (Write(fh, buf, n) != n) {
  1567. X        rc = 0;
  1568. X        break;
  1569. X        }
  1570. X    }
  1571. X    Close(fh);
  1572. X    }
  1573. X    DWrite(chan, &rc, 1);
  1574. X}
  1575. X
  1576. END_OF_FILE
  1577. if test 1398 -ne `wc -c <'amiga/server/sprint.c'`; then
  1578.     echo shar: \"'amiga/server/sprint.c'\" unpacked with wrong size!
  1579. fi
  1580. # end of 'amiga/server/sprint.c'
  1581. fi
  1582. if test -f 'unix/client/draw.c' -a "${1}" != "-c" ; then 
  1583.   echo shar: Will not clobber existing file \"'unix/client/draw.c'\"
  1584. else
  1585. echo shar: Extracting \"'unix/client/draw.c'\" \(1617 characters\)
  1586. sed "s/^X//" >'unix/client/draw.c' <<'END_OF_FILE'
  1587. X
  1588. X/*
  1589. X *    DRAW.C
  1590. X *
  1591. X *    DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
  1592. X *
  1593. X *    DRAW [port#]
  1594. X *
  1595. X *    Put terminal into RAW mode and connect to the remote dnet port.
  1596. X *    used mainly to test DNET.  Can also be used open a TERM window on
  1597. X *    the amiga (via the STERM server), which is the default (port 8195)
  1598. X */
  1599. X
  1600. X
  1601. X
  1602. X#include <sys/types.h>
  1603. X#include <sys/ioctl.h>
  1604. X#include <stdio.h>
  1605. X#include <sys/file.h>
  1606. X#include <signal.h>
  1607. X#include <errno.h>
  1608. X#include "../server/servers.h"
  1609. X
  1610. Xint fd;
  1611. Xchar buf[4096];
  1612. X
  1613. Xmain(ac,av)
  1614. Xchar *av[];
  1615. X{
  1616. X    int n;
  1617. X    extern int handler();
  1618. X    int port = (av[1]) ? atoi(av[1]) : PORT_AMIGATERM;
  1619. X
  1620. X    puts("DRAW V1.01 11 March 1988 Connecting");
  1621. X    fd = DOpen(NULL, port, 0, 0);
  1622. X    if (fd < 0) {
  1623. X    perror("DOpen");
  1624. X    exit(1);
  1625. X    }
  1626. X    puts("Connected");
  1627. X    signal(SIGIO, handler);
  1628. X    ttyraw();
  1629. X    fcntl(fd, F_SETOWN, getpid());
  1630. X    fcntl(fd, F_SETFL, FNDELAY|FASYNC);
  1631. X    fcntl(0,  F_SETFL, FNDELAY);
  1632. X    while ((n = gread(0, buf, sizeof(buf))) > 0) {
  1633. X    gwrite(fd, buf, n);
  1634. X    }
  1635. X    fprintf(stderr, "EOF\n");
  1636. X    DEof(fd);
  1637. X    for (;;)
  1638. X    pause();
  1639. X}
  1640. X
  1641. Xhandler()
  1642. X{
  1643. X    int n;
  1644. X    char buf[1024];
  1645. X
  1646. X    while ((n = read(fd, buf, sizeof(buf))) > 0) 
  1647. X    write(1, buf, n);
  1648. X    if (n == 0) {
  1649. X    write(1, "REMEOF\n", 7);
  1650. X    ttynormal();
  1651. X    exit(1);
  1652. X    }
  1653. X}
  1654. X
  1655. Xstatic struct sgttyb ttym;
  1656. X
  1657. Xttyraw()
  1658. X{
  1659. X    ioctl (0, TIOCGETP, &ttym);
  1660. X    ttym.sg_flags |= RAW;
  1661. X    ttym.sg_flags &= ~CBREAK;
  1662. X    ttym.sg_flags &= ~ECHO;
  1663. X    ioctl (0, TIOCSETP, &ttym);
  1664. X}
  1665. X
  1666. Xttynormal()
  1667. X{
  1668. X    ioctl (0, TIOCGETP, &ttym);
  1669. X    ttym.sg_flags &= ~RAW;
  1670. X    ttym.sg_flags |= CBREAK;
  1671. X    ttym.sg_flags |= ECHO;
  1672. X    ioctl (0, TIOCSETP, &ttym);
  1673. X}
  1674. X
  1675. END_OF_FILE
  1676. if test 1617 -ne `wc -c <'unix/client/draw.c'`; then
  1677.     echo shar: \"'unix/client/draw.c'\" unpacked with wrong size!
  1678. fi
  1679. # end of 'unix/client/draw.c'
  1680. fi
  1681. if test -f 'unix/client/dsoc.c' -a "${1}" != "-c" ; then 
  1682.   echo shar: Will not clobber existing file \"'unix/client/dsoc.c'\"
  1683. else
  1684. echo shar: Extracting \"'unix/client/dsoc.c'\" \(1216 characters\)
  1685. sed "s/^X//" >'unix/client/dsoc.c' <<'END_OF_FILE'
  1686. X
  1687. X/*
  1688. X *    DSOC.C
  1689. X *
  1690. X *    DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
  1691. X *
  1692. X *    DSOC [port#]
  1693. X *
  1694. X *      Connect to the specified port# .. Used to connect to a remote CLI
  1695. X *    (s_shell server on the Amiga, which requires PIPE: to work, port 8196,
  1696. X *    is the default)
  1697. X *
  1698. X *    Uses standard cooked mode instead of RAW mode.
  1699. X */
  1700. X
  1701. X
  1702. X#include <sys/types.h>
  1703. X#include <sys/ioctl.h>
  1704. X#include <stdio.h>
  1705. X#include <sys/file.h>
  1706. X#include <signal.h>
  1707. X#include <errno.h>
  1708. X#include "../server/servers.h"
  1709. X
  1710. Xint fd;
  1711. Xchar buf[2048];
  1712. X
  1713. Xmain(ac,av)
  1714. Xchar *av[];
  1715. X{
  1716. X    int n;
  1717. X    extern int handler();
  1718. X    int port = (av[1]) ? atoi(av[1]) : PORT_AMIGASHELL;
  1719. X
  1720. X    puts("DSOC V1.01 11 March 1988 Connecting");
  1721. X    fd = DOpen(NULL, port, 0, 0);
  1722. X    if (fd < 0) {
  1723. X    perror("DOpen");
  1724. X    exit(1);
  1725. X    }
  1726. X    puts("Connected");
  1727. X    signal(SIGIO, handler);
  1728. X    fcntl(fd, F_SETOWN, getpid());
  1729. X    fcntl(fd, F_SETFL, FNDELAY|FASYNC);
  1730. X    while ((n = gread(0, buf, sizeof(buf))) > 0) {
  1731. X    gwrite(fd, buf, n);
  1732. X    }
  1733. X    fprintf(stderr, "EOF\n");
  1734. X    DEof(fd);
  1735. X    for (;;)
  1736. X    pause();
  1737. X}
  1738. X
  1739. Xhandler()
  1740. X{
  1741. X    int n;
  1742. X    char buf[1024];
  1743. X
  1744. X    while ((n = read(fd, buf, sizeof(buf))) > 0) 
  1745. X    write(1, buf, n);
  1746. X    if (n == 0) {
  1747. X    write(1, "REMEOF\n", 7);
  1748. X    exit(1);
  1749. X    }
  1750. X}
  1751. X
  1752. END_OF_FILE
  1753. if test 1216 -ne `wc -c <'unix/client/dsoc.c'`; then
  1754.     echo shar: \"'unix/client/dsoc.c'\" unpacked with wrong size!
  1755. fi
  1756. # end of 'unix/client/dsoc.c'
  1757. fi
  1758. if test -f 'unix/dnet/channel.h' -a "${1}" != "-c" ; then 
  1759.   echo shar: Will not clobber existing file \"'unix/dnet/channel.h'\"
  1760. else
  1761. echo shar: Extracting \"'unix/dnet/channel.h'\" \(2033 characters\)
  1762. sed "s/^X//" >'unix/dnet/channel.h' <<'END_OF_FILE'
  1763. X
  1764. X/*
  1765. X *  CHANNEL.H
  1766. X *
  1767. X *    DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
  1768. X *
  1769. X *  Channel structures for SCMD_* channel commands.
  1770. X *
  1771. X *  NOTE: These structures may be ONLY 0,2,4, or 6 bytes in size.
  1772. X */
  1773. X
  1774. X#define CSWITCH struct _CSWITCH
  1775. X#define COPEN    struct _COPEN
  1776. X#define CCLOSE    struct _CCLOSE
  1777. X#define CACKCMD struct _CACKCMD
  1778. X#define CEOFCMD struct _CEOFCMD
  1779. X#define CIOCTL  struct _CIOCTL
  1780. X
  1781. XCSWITCH {        /*  SWITCH current data channel */
  1782. X    ubyte   chanh;    /*  channel to switch to    */
  1783. X    ubyte   chanl;
  1784. X};
  1785. X
  1786. XCOPEN {         /*  OPEN port on channel    */
  1787. X    ubyte   chanh;    /*  try to use this channel     */
  1788. X    ubyte   chanl;
  1789. X    ubyte   porth;    /*  requested port from client  */
  1790. X    ubyte   portl;
  1791. X    ubyte   error;    /*  error return 0=ok        */
  1792. X    char    pri;    /*  chan. priority -127 to 126  */
  1793. X};
  1794. X
  1795. XCCLOSE {        /*  CLOSE a channel        */
  1796. X    ubyte   chanh;    /*  channel to close        */
  1797. X    ubyte   chanl;
  1798. X};
  1799. X
  1800. XCACKCMD {        /*  Acknowledge an open            */
  1801. X    ubyte   chanh;    /*  channel               */
  1802. X    ubyte   chanl;
  1803. X    ubyte   error;    /*  0=ok 1=fail 33=retry w/ different channel    */
  1804. X    ubyte   filler;
  1805. X};
  1806. X
  1807. XCEOFCMD {        /*  Send [R/W] EOF        */
  1808. X    ubyte   chanh;    /*  channel to send EOF on    */
  1809. X    ubyte   chanl;
  1810. X    ubyte   flags;    /*  CHANF_ROK/WOK (bits to clear)  */
  1811. X    ubyte   filler;
  1812. X};
  1813. X
  1814. XCIOCTL {
  1815. X    ubyte   chanh;    /* channel            */
  1816. X    ubyte   chanl;
  1817. X    ubyte   cmd;    /* ioctl command        */
  1818. X    ubyte   valh;    /* ioctl value            */
  1819. X    ubyte   vall;
  1820. X    ubyte   valaux;    /* auxillary field        */
  1821. X};
  1822. X
  1823. X#define CIO_SETROWS    1    /* PTY's only            */
  1824. X#define CIO_SETCOLS    2    /* PTY's only            */
  1825. X#define CIO_STOP    3    /* any channel, flow control    */
  1826. X#define CIO_START    4    /* any channel, flow control    */
  1827. X#define CIO_FLUSH    5    /* any channel, flush pending     */  
  1828. X                /* writes down the toilet    */
  1829. X
  1830. X#define CHAN    struct _CHAN
  1831. X
  1832. XCHAN {
  1833. X    int        fd;        /*    file descriptor for channel        */
  1834. X    uword   port;    /*    port#  (used in open sequence)        */
  1835. X    ubyte   state;    /*    state of channel            */
  1836. X    ubyte   flags;    /*    channel flags                */
  1837. X    char    pri;    /*    priority of channel            */
  1838. X};
  1839. X
  1840. END_OF_FILE
  1841. if test 2033 -ne `wc -c <'unix/dnet/channel.h'`; then
  1842.     echo shar: \"'unix/dnet/channel.h'\" unpacked with wrong size!
  1843. fi
  1844. # end of 'unix/dnet/channel.h'
  1845. fi
  1846. if test -f 'unix/dnet/dataconv.c' -a "${1}" != "-c" ; then 
  1847.   echo shar: Will not clobber existing file \"'unix/dnet/dataconv.c'\"
  1848. else
  1849. echo shar: Extracting \"'unix/dnet/dataconv.c'\" \(2362 characters\)
  1850. sed "s/^X//" >'unix/dnet/dataconv.c' <<'END_OF_FILE'
  1851. X
  1852. X/*
  1853. X *  DATACONV.C
  1854. X *
  1855. X *  Data Conversion.
  1856. X */
  1857. X
  1858. Xtypedef unsigned char ubyte;
  1859. Xtypedef unsigned short uword;
  1860. Xtypedef unsigned long ulong;
  1861. X
  1862. Xextern ubyte DDebug;
  1863. X
  1864. Xint
  1865. XCompress7(s, db, n)
  1866. Xubyte *s;
  1867. Xubyte *db;
  1868. Xuword n;    /*    actual source bytes */
  1869. X{
  1870. X    ubyte *d = db;
  1871. X
  1872. X    while (n) {
  1873. X    *d++ = *s++ << 1;
  1874. X
  1875. X    if (--n == 0)
  1876. X        break;
  1877. X    d[-1] |= *s >> 6;
  1878. X    *d++ = *s++ << 2;
  1879. X
  1880. X    if (--n == 0)
  1881. X        break;
  1882. X    d[-1] |= *s >> 5;
  1883. X    *d++ = *s++ << 3;
  1884. X
  1885. X    if (--n == 0)
  1886. X        break;
  1887. X    d[-1] |= *s >> 4;
  1888. X    *d++ = *s++ << 4;
  1889. X
  1890. X    if (--n == 0)
  1891. X        break;
  1892. X    d[-1] |= *s >> 3;
  1893. X    *d++ = *s++ << 5;
  1894. X
  1895. X    if (--n == 0)
  1896. X        break;
  1897. X    d[-1] |= *s >> 2;
  1898. X    *d++ = *s++ << 6;
  1899. X
  1900. X    if (--n == 0)
  1901. X        break;
  1902. X    d[-1] |= *s >> 1;
  1903. X    *d++ = *s++ << 7;
  1904. X
  1905. X    if (--n == 0)
  1906. X        break;
  1907. X    d[-1] |= *s++;
  1908. X    --n;
  1909. X    }
  1910. X    return(d - db);
  1911. X}
  1912. X
  1913. Xvoid
  1914. XUnCompress7(s, d, n)
  1915. Xubyte *s;
  1916. Xubyte *d;
  1917. Xuword n;    /*    actual destination bytes */
  1918. X{
  1919. X    while (n) {
  1920. X    *d++ = s[0] >> 1;
  1921. X
  1922. X    if (--n == 0)
  1923. X        break;
  1924. X    *d++ = ((s[0] << 6) | (s[1] >> 2)) & 0x7F;
  1925. X
  1926. X    if (--n == 0)
  1927. X        break;
  1928. X    *d++ = ((s[1] << 5) | (s[2] >> 3)) & 0x7F;
  1929. X
  1930. X    if (--n == 0)
  1931. X        break;
  1932. X    *d++ = ((s[2] << 4) | (s[3] >> 4)) & 0x7F;
  1933. X
  1934. X    if (--n == 0)
  1935. X        break;
  1936. X    *d++ = ((s[3] << 3) | (s[4] >> 5)) & 0x7F;
  1937. X
  1938. X    if (--n == 0)
  1939. X        break;
  1940. X    *d++ = ((s[4] << 2) | (s[5] >> 6)) & 0x7F;
  1941. X
  1942. X    if (--n == 0)
  1943. X        break;
  1944. X    *d++ = ((s[5] << 1) | (s[6] >> 7)) & 0x7F;
  1945. X
  1946. X    if (--n == 0)
  1947. X        break;
  1948. X    *d++ = s[6] & 0x7F;
  1949. X
  1950. X    --n;
  1951. X    s += 7;
  1952. X    }
  1953. X}
  1954. X
  1955. X
  1956. Xint
  1957. XExpand6(s, db, n)
  1958. Xubyte *s;
  1959. Xubyte *db;
  1960. Xuword n;    /*    actual source bytes */
  1961. X{
  1962. X    ubyte *d = db;
  1963. X    ubyte *sb= s;
  1964. X
  1965. X    while (n) {
  1966. X    *d++ = 0x40 | (*s >> 2);
  1967. X    *d++ = 0x40 | ((*s++ & 3) << 4);
  1968. X    if (--n) {
  1969. X        d[-1] |= *s >> 4;
  1970. X        *d++ = 0x40 | ((*s++ & 0x0F) << 2);
  1971. X        if (--n) {
  1972. X        d[-1] |= *s >> 6;
  1973. X        *d++ = 0x40 | (*s++ & 0x3F);
  1974. X        --n;
  1975. X        }
  1976. X    }
  1977. X    }
  1978. X    if (DDebug)
  1979. X    printf("e6: %02x %02x -> %02x %02x %02x\n", 
  1980. X        sb[0], sb[1],
  1981. X        db[0], db[1], db[2]
  1982. X    );
  1983. X    return(d - db);
  1984. X}
  1985. X
  1986. Xvoid
  1987. XUnExpand6(s, d, n)
  1988. Xubyte *s;
  1989. Xubyte *d;
  1990. Xuword n;    /*    actual destination bytes */
  1991. X{
  1992. X    ubyte *sb = s;
  1993. X    ubyte *db = d;
  1994. X
  1995. X    while (n) {
  1996. X    *d++ = (s[0] << 2) | ((s[1] & 0x30) >> 4);
  1997. X    if (--n == 0)
  1998. X        break;
  1999. X    *d++ = (s[1] << 4) | ((s[2] & 0x3C) >> 2);
  2000. X    if (--n == 0)
  2001. X        break;
  2002. X    *d++ = (s[2] << 6) | (s[3] & 0x3F);
  2003. X    --n;
  2004. X    s += 4;
  2005. X    }
  2006. X    if (DDebug)
  2007. X    printf("d6: %02x %02x <- %02x %02x %02x\n", 
  2008. X        db[0], db[1],
  2009. X        sb[0], sb[1], sb[2]
  2010. X    );
  2011. X}
  2012. X
  2013. X
  2014. X
  2015. END_OF_FILE
  2016. if test 2362 -ne `wc -c <'unix/dnet/dataconv.c'`; then
  2017.     echo shar: \"'unix/dnet/dataconv.c'\" unpacked with wrong size!
  2018. fi
  2019. # end of 'unix/dnet/dataconv.c'
  2020. fi
  2021. if test -f 'unix/dnet/double.c' -a "${1}" != "-c" ; then 
  2022.   echo shar: Will not clobber existing file \"'unix/dnet/double.c'\"
  2023. else
  2024. echo shar: Extracting \"'unix/dnet/double.c'\" \(1589 characters\)
  2025. sed "s/^X//" >'unix/dnet/double.c' <<'END_OF_FILE'
  2026. X
  2027. X/*
  2028. X *  DOUBLE
  2029. X *
  2030. X *  DOUBLE DNETDIRA DNETDIRB
  2031. X *
  2032. X *  Run dnet using a pipe (for testing)
  2033. X */
  2034. X
  2035. X#include <stdio.h>
  2036. X#include <fcntl.h>
  2037. X#include <sys/types.h>
  2038. X#include <sys/socket.h>
  2039. X#include <netinet/in.h>
  2040. X#include <netdb.h>
  2041. X
  2042. Xmain(ac, av, envp)
  2043. Xchar *av[];
  2044. Xchar **envp;
  2045. X{
  2046. X    int files[2];
  2047. X    short i;
  2048. X    char buf[256];
  2049. X    char cmd[256];
  2050. X
  2051. X    if (ac != 3) {
  2052. X    puts("double dnetdira dnetdirb");
  2053. X    exit(1);
  2054. X    }
  2055. X
  2056. X    for (i = 0; envp[i]; ++i) {
  2057. X    if (strncmp(envp[i], "DNETDIR=", 8) == 0)
  2058. X        break;
  2059. X    }
  2060. X    if (envp[i] == NULL) {
  2061. X    puts("must set a dummy DNETDIR enviroment variable");
  2062. X    exit(1);
  2063. X    }
  2064. X
  2065. X
  2066. X    if (socketpair(AF_UNIX, SOCK_STREAM, 0, files) < 0) {
  2067. X    perror("socketpair");
  2068. X    exit(1);
  2069. X    }
  2070. X
  2071. X    envp[i] = buf;
  2072. X    if (fork() == 0) {
  2073. X    int fd = open("d1.log", O_WRONLY | O_CREAT | O_TRUNC, 0666);
  2074. X    if (dup2(files[0], 0) < 0)
  2075. X        perror("dup2-1");
  2076. X    dup2(fd, 1);
  2077. X    dup2(fd, 2);
  2078. X    if (write(0, "", 0) < 0) {
  2079. X        perror("write");
  2080. X        exit(1);
  2081. X    }
  2082. X        sprintf(buf, "DNETDIR=%s", av[1]);
  2083. X    execlp("dnet", "dnet", "debug", NULL);
  2084. X    perror("exec");
  2085. X    exit(1);
  2086. X    }
  2087. X    if (fork() == 0) {
  2088. X    int fd = open("d2.log", O_WRONLY | O_CREAT | O_TRUNC, 0666);
  2089. X    if (dup2(files[1], 0) < 0)
  2090. X        perror("dup2-1");
  2091. X    dup2(fd, 1);
  2092. X    dup2(fd, 2);
  2093. X    close(files[0]);
  2094. X    close(files[1]);
  2095. X    if (write(0, "", 0) < 0) {
  2096. X        perror("write");
  2097. X        exit(1);
  2098. X    }
  2099. X        sprintf(buf, "DNETDIR=%s", av[2]);
  2100. X    execlp("dnet", "dnet", "debug", NULL);
  2101. X    perror("exec");
  2102. X    exit(1);
  2103. X    }
  2104. X    close(files[0]);
  2105. X    close(files[1]);
  2106. X    {
  2107. X    int pid;
  2108. X        while ((pid = wait(0)) > 0)
  2109. X        printf("pid %d exit\n", pid);
  2110. X    }
  2111. X}
  2112. X
  2113. END_OF_FILE
  2114. if test 1589 -ne `wc -c <'unix/dnet/double.c'`; then
  2115.     echo shar: \"'unix/dnet/double.c'\" unpacked with wrong size!
  2116. fi
  2117. # end of 'unix/dnet/double.c'
  2118. fi
  2119. if test -f 'unix/dnet/files.c' -a "${1}" != "-c" ; then 
  2120.   echo shar: Will not clobber existing file \"'unix/dnet/files.c'\"
  2121. else
  2122. echo shar: Extracting \"'unix/dnet/files.c'\" \(3476 characters\)
  2123. sed "s/^X//" >'unix/dnet/files.c' <<'END_OF_FILE'
  2124. X
  2125. X/*
  2126. X * FILES.C
  2127. X *
  2128. X *    DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
  2129. X *
  2130. X *    handles actions on a per file descriptor basis, including accepting
  2131. X *    new connections, closing old connections, and transfering data
  2132. X *    between connections.
  2133. X */
  2134. X
  2135. X#include "dnet.h"
  2136. X
  2137. Xextern void do_localopen(), do_connect(), do_open1(), do_openwait(), do_open();
  2138. X
  2139. X/*
  2140. X *  new connection over master port... open request.  read two byte port
  2141. X *  number, allocate a channel, and send off to the remote
  2142. X */
  2143. X
  2144. Xvoid
  2145. Xdo_localopen(n, fd)
  2146. X{
  2147. X    struct sockaddr sa;
  2148. X    int addrlen = sizeof(sa);
  2149. X    int s;
  2150. X    uword chan;
  2151. X
  2152. X    if (DDebug)
  2153. X    fprintf(stderr, "DO_LOCALOPEN %ld %ld\n", n, fd);
  2154. X    while ((s = accept(fd, &sa, &addrlen)) >= 0) {
  2155. X    chan = alloc_channel();
  2156. X    fcntl(s, F_SETFL, FNDELAY);
  2157. X    if (DDebug)
  2158. X        fprintf(stderr, " ACCEPT: %ld on channel %ld ", s, chan);
  2159. X    if (chan == 0xFFFF) {
  2160. X        ubyte error = 1;
  2161. X        gwrite(s, &error, 1);
  2162. X        close(s);
  2163. X        if (DDebug)
  2164. X            fprintf(stderr, "(no channels)\n");
  2165. X        continue;
  2166. X    } 
  2167. X    Fdstate[s] = do_open1;
  2168. X    FdChan[s] = chan;
  2169. X    FD_SET(s, &Fdread);
  2170. X    FD_SET(s, &Fdexcept);
  2171. X    Chan[chan].fd = s;
  2172. X    Chan[chan].state = CHAN_LOPEN;
  2173. X    if (DDebug)
  2174. X        fprintf(stderr, "(State = CHAN_LOPEN)\n");
  2175. X    }
  2176. X}
  2177. X
  2178. Xvoid
  2179. Xdo_open1(n_notused, fd)
  2180. X{
  2181. X    uword port;
  2182. X    char  trxpri[2];
  2183. X    uword chan = FdChan[fd];
  2184. X    COPEN co;
  2185. X    int n;
  2186. X
  2187. X    if (DDebug)
  2188. X    fprintf(stderr, "DO_OPEN %ld %ld on channel %ld  ", n, fd, chan);
  2189. X    for (;;) {
  2190. X        n = read(fd, &port, 2);
  2191. X    if (n < 0) {
  2192. X        if (errno == EINTR)
  2193. X        continue;
  2194. X        if (errno == EWOULDBLOCK)
  2195. X        return;
  2196. X    }
  2197. X    read(fd, trxpri, 2);
  2198. X    if (n != 2)
  2199. X        dneterror("do_open1: unable to read 2 bytes");
  2200. X    break;
  2201. X    }
  2202. X    if (DDebug)
  2203. X    fprintf(stderr, "Port %ld\n", port);
  2204. X    co.chanh = chan >> 8;
  2205. X    co.chanl = chan;
  2206. X    co.porth = port >> 8;
  2207. X    co.portl = port;
  2208. X    co.error = 0;
  2209. X    co.pri   = trxpri[1];
  2210. X    Chan[chan].port = port;
  2211. X    Chan[chan].pri = 126;
  2212. X    WriteStream(SCMD_OPEN, &co, sizeof(co), chan);
  2213. X    Chan[chan].pri = trxpri[0];
  2214. X    Fdstate[fd] = do_openwait;
  2215. X    if (DDebug)
  2216. X        fprintf(stderr, " Newstate = openwait\n");
  2217. X}
  2218. X
  2219. Xvoid
  2220. Xdo_openwait(n, fd)
  2221. X{
  2222. X    ubyte buf[32];
  2223. X    if (DDebug)
  2224. X    fprintf(stderr, "************ ERROR DO_OPENWAIT %ld %ld\n", n, fd);
  2225. X    n = read(fd, buf, 32);
  2226. X    if (DDebug) {
  2227. X    fprintf(stderr, "    OPENWAIT, READ %ld bytes\n", n);
  2228. X        if (n < 0)
  2229. X        perror("openwait:read");
  2230. X    }
  2231. X}
  2232. X
  2233. Xvoid
  2234. Xdo_open(nn, fd)
  2235. X{
  2236. X    extern void nop();
  2237. X    char buf[256];
  2238. X    uword chan = FdChan[fd];
  2239. X    int n;
  2240. X
  2241. X    n = read(fd, buf, sizeof(buf));
  2242. X    if (DDebug) {
  2243. X    fprintf(stderr, "DO_OPEN %ld %ld, RECEIVE DATA on chan %ld (%ld by)\n",
  2244. X        nn, fd, chan, n);
  2245. X    fprintf(stderr, " fd, chanfd %ld %ld\n", fd, Chan[chan].fd);
  2246. X    if (n < 0)
  2247. X        perror("open:read");
  2248. X    }
  2249. X    if (n == 0 || nn == 2) {    /* application closed / exception cond */
  2250. X    CCLOSE cc;
  2251. X
  2252. X    if (DDebug)
  2253. X        fprintf(stderr, " DO_OPEN: REMOTE EOF, channel %d\n", chan);
  2254. X
  2255. X    cc.chanh = chan >> 8;
  2256. X    cc.chanl = chan;
  2257. X    WriteStream(SCMD_CLOSE, &cc, sizeof(CCLOSE), chan);
  2258. X    Chan[chan].state = CHAN_CLOSE;
  2259. X    Chan[chan].flags |= CHANF_LCLOSE;
  2260. X    if (Chan[chan].flags & CHANF_RCLOSE) {
  2261. X        ;
  2262. X        /* should never happen
  2263. X        int fd = Chan[chan].fd;
  2264. X        Chan[chan].state = CHAN_FREE;
  2265. X        Chan[chan].fd = -1;
  2266. X        Fdstate[fd] = nop;
  2267. X        FD_CLR(fd, &Fdread);
  2268. X        FD_CLR(fd, &Fdexcept);
  2269. X        close(fd);
  2270. X        */
  2271. X    } else {
  2272. X        FD_CLR(fd, &Fdread);
  2273. X        FD_CLR(fd, &Fdexcept);
  2274. X    }
  2275. X    }
  2276. X    if (n > 0) {
  2277. X    WriteStream(SCMD_DATA, buf, n, chan);
  2278. X    }
  2279. X}
  2280. X
  2281. END_OF_FILE
  2282. if test 3476 -ne `wc -c <'unix/dnet/files.c'`; then
  2283.     echo shar: \"'unix/dnet/files.c'\" unpacked with wrong size!
  2284. fi
  2285. # end of 'unix/dnet/files.c'
  2286. fi
  2287. if test -f 'unix/dnet/net.c' -a "${1}" != "-c" ; then 
  2288.   echo shar: Will not clobber existing file \"'unix/dnet/net.c'\"
  2289. else
  2290. echo shar: Extracting \"'unix/dnet/net.c'\" \(1968 characters\)
  2291. sed "s/^X//" >'unix/dnet/net.c' <<'END_OF_FILE'
  2292. X
  2293. X/*
  2294. X *  NET.C
  2295. X *
  2296. X *    DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
  2297. X *
  2298. X *  NetWork raw device interface.  Replace with whatever interface you
  2299. X *  want.
  2300. X */
  2301. X
  2302. X#include "dnet.h"
  2303. X#include <sys/stat.h>
  2304. X
  2305. XRcvInt()
  2306. X{
  2307. X    int n = read(0, RcvBuf + RcvData, RCVBUF - RcvData);
  2308. X    int i;
  2309. X    extern int errno;
  2310. X
  2311. X    errno = 0;
  2312. X    if (n >= 0)
  2313. X    RcvData += n;
  2314. X    if (n <= 0)         /* disallow infinite fast-timeout select loops */
  2315. X    RExpect = 0;
  2316. X    if (DDebug)
  2317. X    printf("read(%d,%d)\n", n, errno);
  2318. X}
  2319. X
  2320. Xstatic struct sgttyb    ttym;
  2321. Xstatic struct stat    Stat;
  2322. X
  2323. XNetOpen()
  2324. X{
  2325. X    int async = 1;
  2326. X
  2327. X    fstat(0, &Stat);
  2328. X    fchmod(0, 0600);
  2329. X    /*
  2330. X    signal(SIGIO, RcvInt);
  2331. X    */
  2332. X    ioctl (0, TIOCGETP, &ttym);
  2333. X    if (Mode7) {
  2334. X        ttym.sg_flags &= ~RAW;
  2335. X        ttym.sg_flags |= CBREAK;
  2336. X    } else {
  2337. X        ttym.sg_flags |= RAW;
  2338. X        ttym.sg_flags &= ~CBREAK;
  2339. X    }
  2340. X    ttym.sg_flags &= ~ECHO;
  2341. X    ioctl (0, TIOCSETP, &ttym);
  2342. X    /*
  2343. X    ioctl (0, FIOASYNC, &async);
  2344. X    */
  2345. X    ioctl (0, FIONBIO, &async);
  2346. X}
  2347. X
  2348. XNetClose()
  2349. X{
  2350. X    int async = 0;
  2351. X
  2352. X    fchmod(0, Stat.st_mode);
  2353. X    ioctl (0, FIONBIO, &async);
  2354. X    /*
  2355. X    ioctl (0, FIOASYNC, &async);
  2356. X    */
  2357. X    ioctl (0, TIOCGETP, &ttym);
  2358. X    ttym.sg_flags &= ~RAW;
  2359. X    ttym.sg_flags |= ECHO;
  2360. X    ioctl (0, TIOCSETP, &ttym);
  2361. X}
  2362. X
  2363. XNetWrite(buf, bytes)
  2364. Xubyte *buf;
  2365. X{
  2366. X    if (DDebug)
  2367. X    fprintf(stderr, "NETWRITE %08lx %ld\n", buf, bytes);
  2368. X    gwrite(0, buf, bytes);
  2369. X}
  2370. X
  2371. Xgwrite(fd, buf, bytes)
  2372. Xregister char *buf;
  2373. Xregister long bytes;
  2374. X{
  2375. X    register long n;
  2376. X    while (bytes) {
  2377. X    n = write(fd, buf, bytes);
  2378. X    if (n > 0) {
  2379. X        bytes -= n;
  2380. X        buf += n;
  2381. X        continue;
  2382. X    }
  2383. X    if (errno == EINTR)
  2384. X        continue;
  2385. X    if (errno == EWOULDBLOCK) {
  2386. X        fd_set fd_wr;
  2387. X        fd_set fd_ex;
  2388. X        FD_ZERO(&fd_wr);
  2389. X        FD_ZERO(&fd_ex);
  2390. X        FD_SET(fd, &fd_wr);
  2391. X        FD_SET(fd, &fd_ex);
  2392. X        if (select(fd+1, NULL, &fd_wr, &fd_ex, NULL) < 0) {
  2393. X         perror("select");
  2394. X        }
  2395. X        continue;
  2396. X    }
  2397. X    if (errno == EPIPE)
  2398. X        return;
  2399. X    dneterror("gwrite");
  2400. X    }
  2401. X}
  2402. X
  2403. END_OF_FILE
  2404. if test 1968 -ne `wc -c <'unix/dnet/net.c'`; then
  2405.     echo shar: \"'unix/dnet/net.c'\" unpacked with wrong size!
  2406. fi
  2407. # end of 'unix/dnet/net.c'
  2408. fi
  2409. if test -f 'unix/server/scopy.c' -a "${1}" != "-c" ; then 
  2410.   echo shar: Will not clobber existing file \"'unix/server/scopy.c'\"
  2411. else
  2412. echo shar: Extracting \"'unix/server/scopy.c'\" \(3081 characters\)
  2413. sed "s/^X//" >'unix/server/scopy.c' <<'END_OF_FILE'
  2414. X
  2415. X/*
  2416. X *    SCOPY.C
  2417. X *
  2418. X *    DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
  2419. X *
  2420. X *    Remote file copy server (putfiles is the client program)
  2421. X */
  2422. X
  2423. X#include <sys/types.h>
  2424. X#include <sys/stat.h>
  2425. X#include <sys/wait.h>
  2426. X#include <sys/time.h>
  2427. X#include <sys/file.h>
  2428. X#include <sys/resource.h>
  2429. X#include <stdio.h>
  2430. X#include <errno.h>
  2431. X#include <signal.h>
  2432. X
  2433. X#include "servers.h"
  2434. X#include "../lib/dnetlib.h"
  2435. X
  2436. Xchar Buf[4096];
  2437. X
  2438. Xchandler()
  2439. X{
  2440. X    union wait stat;
  2441. X    struct rusage rus;
  2442. X    while (wait3(&stat, WNOHANG, &rus) > 0);
  2443. X}
  2444. X
  2445. Xmain(ac,av)
  2446. Xchar *av[];
  2447. X{
  2448. X    long chann = DListen(PORT_FILECOPY);
  2449. X    int fd;
  2450. X    int n;
  2451. X    char buf[256];
  2452. X    extern int errno;
  2453. X
  2454. X    elog(EDEBUG, "SCOPY START", 0);
  2455. X    if (av[1])
  2456. X        chdir(av[1]);
  2457. X    signal(SIGCHLD, chandler);
  2458. X    signal(SIGPIPE, SIG_IGN);
  2459. X    for (;;) {
  2460. X    fd = DAccept(chann);
  2461. X    if (fd < 0) {
  2462. X        if (errno == EINTR)
  2463. X        continue;
  2464. X        break;
  2465. X    }
  2466. X        elog(EDEBUG, "SCOPY CONNECT", 0);
  2467. X    if (fork() == NULL) {
  2468. X        putdir(fd, "."); 
  2469. X        _exit(1);
  2470. X    }
  2471. X    close(fd);
  2472. X    }
  2473. X    perror("SCOPY");
  2474. X}
  2475. X
  2476. Xputdir(chan, dirname)
  2477. Xchar *dirname;
  2478. X{
  2479. X    struct stat stat;
  2480. X    char olddir[256];
  2481. X    char co, nl, name[128];
  2482. X    long len;
  2483. X    int ret = -1;
  2484. X
  2485. X    getwd(olddir);
  2486. X    if (lstat(dirname, &stat) >= 0 && !(stat.st_mode & S_IFDIR)) {
  2487. X    char rc = 'N';
  2488. X    gwrite(chan, &rc, 1);
  2489. X    elog(EWARN, "SCOPY: Unable to cd to dir '%s'", dirname);
  2490. X    return(1);
  2491. X    }
  2492. X    if (chdir(dirname) < 0) {
  2493. X    if (mkdir(dirname, 0777) < 0 || chdir(dirname) < 0) {
  2494. X        char rc = 'N';
  2495. X        elog(EWARN, "SCOPY: Unable to create directory '%s'", dirname);
  2496. X        gwrite(chan, &rc, 1);
  2497. X        return(1);
  2498. X    }
  2499. X    }
  2500. X    co = 'Y';
  2501. X    gwrite(chan, &co, 1);
  2502. X    while (ggread(chan, &co, 1) == 1) {
  2503. X    if (ggread(chan, &nl, 1) != 1 || ggread(chan, name, nl) != nl)
  2504. X        break;
  2505. X    if (ggread(chan, &len, 4) != 4)
  2506. X        break;
  2507. X    len = ntohl68(len);
  2508. X    switch(co) {
  2509. X    case 'C':
  2510. X        co = 'Y';
  2511. X            if (chdir(name) < 0) {
  2512. X        if (mkdir(name, 0777) < 0 || chdir(name) < 0)  {
  2513. X            co = 'N';
  2514. X                elog(EWARN, "SCOPY: Unable to create directory '%s'", 
  2515. X            dirname);
  2516. X        }
  2517. X        }
  2518. X        gwrite(chan, &co, 1);
  2519. X        break;
  2520. X    case 'W':
  2521. X        if (putfile(chan, name, len) < 0) {
  2522. X        ret = -1;
  2523. X        elog(EWARN, "SCOPY: Failure on file %.*s", len, name);
  2524. X        goto fail;
  2525. X        }
  2526. X        break;
  2527. X    case 'X':
  2528. X        if (putdir(chan, name) < 0) {
  2529. X        ret = -1;
  2530. X        goto fail;
  2531. X        }
  2532. X        break;
  2533. X    case 'Y':
  2534. X        ret = 1;
  2535. X        co = 'Y';
  2536. X        gwrite(chan, &co, 1);
  2537. X        goto fail;
  2538. X    default:
  2539. X        co = 'N';
  2540. X        gwrite(chan, &co, 1);
  2541. X        break;
  2542. X    }
  2543. X    }
  2544. Xfail:
  2545. X    chdir(olddir);
  2546. X    return(ret);
  2547. X}
  2548. X
  2549. Xputfile(chan, name, len)
  2550. Xchar *name;
  2551. X{
  2552. X    long fd = open(name, O_WRONLY|O_CREAT|O_TRUNC, 0666);
  2553. X    long n, r;
  2554. X    char rc;
  2555. X
  2556. X    if (fd < 0) {
  2557. X    rc = 'N';
  2558. X    gwrite(chan, &rc, 1);
  2559. X    return(0);
  2560. X    }
  2561. X    rc = 'Y';
  2562. X    gwrite(chan, &rc, 1);
  2563. X    while (len) {
  2564. X    r = (len > sizeof(Buf)) ? sizeof(Buf) : len;
  2565. X    n = ggread(chan, Buf, r);
  2566. X    if (n != r)
  2567. X        break;
  2568. X        if (write(fd, Buf, n) != n)
  2569. X        break;
  2570. X    len -= n;
  2571. X    }
  2572. X    close(fd);
  2573. X    if (len) {
  2574. X    unlink(name);
  2575. X    return(-1);
  2576. X    }
  2577. X    rc = 'Y';
  2578. X    gwrite(chan, &rc, 1);
  2579. X    return(0);
  2580. X}
  2581. X
  2582. END_OF_FILE
  2583. if test 3081 -ne `wc -c <'unix/server/scopy.c'`; then
  2584.     echo shar: \"'unix/server/scopy.c'\" unpacked with wrong size!
  2585. fi
  2586. # end of 'unix/server/scopy.c'
  2587. fi
  2588. if test -f 'unix/server/sloadav.c' -a "${1}" != "-c" ; then 
  2589.   echo shar: Will not clobber existing file \"'unix/server/sloadav.c'\"
  2590. else
  2591. echo shar: Extracting \"'unix/server/sloadav.c'\" \(1227 characters\)
  2592. sed "s/^X//" >'unix/server/sloadav.c' <<'END_OF_FILE'
  2593. X
  2594. X/*
  2595. X *    SLOADAV.C
  2596. X *
  2597. X *    DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
  2598. X *
  2599. X *    Reports the load average every 5 minutes or until the connection
  2600. X *    is closed.
  2601. X */
  2602. X
  2603. X#include <stdio.h>
  2604. X#include <sys/wait.h>
  2605. X#include <sys/time.h>
  2606. X#include <sys/resource.h>
  2607. X#include <errno.h>
  2608. X#include <signal.h>
  2609. X
  2610. X#include "servers.h"
  2611. X
  2612. Xchandler()
  2613. X{
  2614. X    union wait stat;
  2615. X    struct rusage rus;
  2616. X    while (wait3(&stat, WNOHANG, &rus) > 0);
  2617. X}
  2618. X
  2619. Xmain(ac,av)
  2620. Xchar *av[];
  2621. X{
  2622. X    long chann = DListen(PORT_LOADAV);
  2623. X    int fd;
  2624. X    int n;
  2625. X    char buf[256];
  2626. X    extern int errno;
  2627. X
  2628. X    if (av[1])
  2629. X    chdir(av[1]);
  2630. X    signal(SIGCHLD, chandler);
  2631. X    signal(SIGPIPE, SIG_IGN);
  2632. X    for (;;) {
  2633. X    fd = DAccept(chann);
  2634. X    if (fd < 0) {
  2635. X        if (errno == EINTR)
  2636. X        continue;
  2637. X        break;
  2638. X    }
  2639. X    if (fork() == NULL) {
  2640. X        do_loadav(fd);
  2641. X        close(fd);
  2642. X        _exit(1);
  2643. X    }
  2644. X    close(fd);
  2645. X    }
  2646. X    perror("SLOADAV");
  2647. X}
  2648. X
  2649. Xdo_loadav(fd)
  2650. X{
  2651. X    char dummy;
  2652. X    char buf[256];
  2653. X    FILE *fi;
  2654. X
  2655. X    while (ggread(fd, &dummy, 1) == 1) {
  2656. X    fi = popen("uptime", "r");
  2657. X    if (fi == NULL)
  2658. X        break;
  2659. X    if (fgets(buf, 256, fi)) {
  2660. X        dummy = strlen(buf);
  2661. X        buf[dummy-1] = 0;
  2662. X        gwrite(fd, &dummy, 1);
  2663. X        gwrite(fd, buf, dummy);
  2664. X    }
  2665. X    if (ferror(fi))
  2666. X        break;
  2667. X    pclose(fi);
  2668. X    }
  2669. X}
  2670. X
  2671. END_OF_FILE
  2672. if test 1227 -ne `wc -c <'unix/server/sloadav.c'`; then
  2673.     echo shar: \"'unix/server/sloadav.c'\" unpacked with wrong size!
  2674. fi
  2675. # end of 'unix/server/sloadav.c'
  2676. fi
  2677. if test -f 'unix/server/snfs.h' -a "${1}" != "-c" ; then 
  2678.   echo shar: Will not clobber existing file \"'unix/server/snfs.h'\"
  2679. else
  2680. echo shar: Extracting \"'unix/server/snfs.h'\" \(1617 characters\)
  2681. sed "s/^X//" >'unix/server/snfs.h' <<'END_OF_FILE'
  2682. X
  2683. X#define ulong unsigned long
  2684. X#define ubyte unsigned char
  2685. X#define uword unsigned short
  2686. X
  2687. Xtypedef struct {
  2688. X    long    ds_Days;
  2689. X    long    ds_Minute;
  2690. X    long    ds_Tick;
  2691. X} STAMP;
  2692. X
  2693. Xtypedef struct {
  2694. X    long    DirHandle;        /*  relative to directory (0=root)  */
  2695. X    uword   Modes;        /*  open modes                */
  2696. X} OpOpen;
  2697. X
  2698. Xtypedef struct {
  2699. X    long    Handle;
  2700. X    ulong   Prot;
  2701. X    long    Type;
  2702. X    long    Size;
  2703. X    STAMP   Date;
  2704. X} RtOpen;
  2705. X
  2706. X
  2707. Xtypedef struct {
  2708. X    long    Handle;     /*  file handle to read from        */
  2709. X    long    Bytes;        /*  # of bytes to read            */
  2710. X} OpRead;
  2711. X
  2712. Xtypedef struct {
  2713. X    long    Bytes;        /*  < 0 == error            */
  2714. X} RtRead;
  2715. X
  2716. Xtypedef struct {
  2717. X    long   Handle;     /*  file handle to read from        */
  2718. X    long    Bytes;        /*  # of bytes to read            */
  2719. X} OpWrite;
  2720. X
  2721. Xtypedef struct {
  2722. X    long    Bytes;        /*  < 0 == error            */
  2723. X} RtWrite;
  2724. X
  2725. Xtypedef struct {
  2726. X    long    Handle;
  2727. X} OpClose;
  2728. X
  2729. Xtypedef struct {
  2730. X    long    Handle;
  2731. X    long    Offset;
  2732. X    long    How;
  2733. X} OpSeek;
  2734. X
  2735. Xtypedef struct {
  2736. X    long    OldOffset;
  2737. X    long    NewOffset;        /*    -1 = error  */
  2738. X} RtSeek;
  2739. X
  2740. Xtypedef struct {
  2741. X    long    Handle;
  2742. X} OpParent;
  2743. X
  2744. Xtypedef RtOpen RtParent;
  2745. X
  2746. Xtypedef struct {
  2747. X    long    DirHandle;
  2748. X} OpDelete;
  2749. X
  2750. Xtypedef struct {
  2751. X    long    Error;
  2752. X} RtDelete;
  2753. X
  2754. Xtypedef OpDelete OpCreateDir;
  2755. Xtypedef RtParent RtCreateDir;
  2756. X
  2757. Xtypedef struct {
  2758. X    long    Handle;
  2759. X    long    Index;
  2760. X} OpNextDir;
  2761. X
  2762. Xtypedef RtOpen RtNextDir;
  2763. X
  2764. Xtypedef struct {
  2765. X    long    Handle;
  2766. X} OpDup;
  2767. X
  2768. Xtypedef RtOpen    RtDup;
  2769. X
  2770. Xtypedef struct {
  2771. X    long    DirHandle1;
  2772. X    long    DirHandle2;
  2773. X} OpRename;
  2774. X
  2775. Xtypedef struct {
  2776. X    long    Error;
  2777. X} RtRename;
  2778. X
  2779. END_OF_FILE
  2780. if test 1617 -ne `wc -c <'unix/server/snfs.h'`; then
  2781.     echo shar: \"'unix/server/snfs.h'\" unpacked with wrong size!
  2782. fi
  2783. # end of 'unix/server/snfs.h'
  2784. fi
  2785. if test -f 'unix/server/sshell.c' -a "${1}" != "-c" ; then 
  2786.   echo shar: Will not clobber existing file \"'unix/server/sshell.c'\"
  2787. else
  2788. echo shar: Extracting \"'unix/server/sshell.c'\" \(1313 characters\)
  2789. sed "s/^X//" >'unix/server/sshell.c' <<'END_OF_FILE'
  2790. X
  2791. X/*
  2792. X *  S_SHELL.C        OBSOLETE OBSOLETE OBSOLETE
  2793. X *
  2794. X *    DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
  2795. X *
  2796. X *   Connect a csh to a pseudo terminal pair... PORT_ALPHATERM
  2797. X *   NOTE!!  PORT_IALPHATERM (a pseudo-terminal csh) is also available
  2798. X *   through the FTERM client program on the Amiga side, and much faster
  2799. X *   since the server for PORT_IALPHATERM is DNET itself (one less process
  2800. X *   to go through).
  2801. X *
  2802. X *    -doesn't handle SIGWINCH
  2803. X *    -doesn't handle flow control ... don't cat any long files!
  2804. X */
  2805. X
  2806. X#include <stdio.h>
  2807. X#include <sys/wait.h>
  2808. X#include <sys/time.h>
  2809. X#include <sys/resource.h>
  2810. X#include <errno.h>
  2811. X#include <signal.h>
  2812. X
  2813. X#include "servers.h"
  2814. X
  2815. Xchandler()
  2816. X{
  2817. X    union wait stat;
  2818. X    struct rusage rus;
  2819. X    while (wait3(&stat, WNOHANG, &rus) > 0);
  2820. X}
  2821. X
  2822. Xmain(ac,av)
  2823. Xchar *av[];
  2824. X{
  2825. X    long chann = DListen(PORT_ALPHATERM);
  2826. X    int fd;
  2827. X    int n;
  2828. X    char buf[256];
  2829. X    extern int errno;
  2830. X
  2831. X    if (av[1])
  2832. X    chdir(av[1]);
  2833. X    signal(SIGCHLD, chandler);
  2834. X    signal(SIGPIPE, SIG_IGN);
  2835. X    for (;;) {
  2836. X    fd = DAccept(chann);
  2837. X    if (fd < 0) {
  2838. X        if (errno == EINTR)
  2839. X        continue;
  2840. X        break;
  2841. X    }
  2842. X    if (fork() == NULL) {
  2843. X        dup2(fd, 0);
  2844. X        dup2(fd, 1);
  2845. X        dup2(fd, 2);
  2846. X        close(fd);
  2847. X        execl("/usr/ucb/rlogin", "rlogin", "localhost", NULL);
  2848. X        exit(1);
  2849. X    }
  2850. X    close(fd);
  2851. X    }
  2852. X    perror("SSHELL");
  2853. X}
  2854. X
  2855. END_OF_FILE
  2856. if test 1313 -ne `wc -c <'unix/server/sshell.c'`; then
  2857.     echo shar: \"'unix/server/sshell.c'\" unpacked with wrong size!
  2858. fi
  2859. # end of 'unix/server/sshell.c'
  2860. fi
  2861. echo shar: End of archive 2 \(of 8\).
  2862. cp /dev/null ark2isdone
  2863. MISSING=""
  2864. for I in 1 2 3 4 5 6 7 8 ; do
  2865.     if test ! -f ark${I}isdone ; then
  2866.     MISSING="${MISSING} ${I}"
  2867.     fi
  2868. done
  2869. if test "${MISSING}" = "" ; then
  2870.     echo You have unpacked all 8 archives.
  2871.     rm -f ark[1-9]isdone
  2872. else
  2873.     echo You still need to unpack the following archives:
  2874.     echo "        " ${MISSING}
  2875. fi
  2876. ##  End of shell archive.
  2877. exit 0
  2878. -- 
  2879. Mail submissions (sources or binaries) to <amiga@cs.odu.edu>.
  2880. Mail comments to the moderator at <amiga-request@cs.odu.edu>.
  2881. Post requests for sources, and general discussion to comp.sys.amiga.
  2882.